aboutsummaryrefslogtreecommitdiffstats
path: root/toolbox
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2012-06-26 14:59:36 -0700
committerNick Kralevich <nnk@google.com>2012-06-26 14:59:36 -0700
commit3f2b0a506f1e09e6960c050778870da289fc4702 (patch)
tree52cf8a78309fcf1a860dde76983f77ac4aa6f6bc /toolbox
parent22aec573b718c57aea2b9bd91607631a6d521911 (diff)
downloadsystem_core-3f2b0a506f1e09e6960c050778870da289fc4702.tar.gz
system_core-3f2b0a506f1e09e6960c050778870da289fc4702.tar.bz2
system_core-3f2b0a506f1e09e6960c050778870da289fc4702.zip
Add mode when open(O_CREAT) is used.
When creating a new file using open(..., O_CREAT), it is an error to fail to specify a creation mode. If a mode is not specified, a random stack provided value is used as the "mode". This will become a runtime error in a future version of Android. Change-Id: I00609f37d2ea68e21b6404d542830386be354202
Diffstat (limited to 'toolbox')
-rw-r--r--toolbox/dd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/toolbox/dd.c b/toolbox/dd.c
index 53a6206c..350f1d2d 100644
--- a/toolbox/dd.c
+++ b/toolbox/dd.c
@@ -95,6 +95,7 @@ extern const u_char *ctab;
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#define DEFFILEMODE (S_IRUSR | S_IWUSR)
static void dd_close(void);
static void dd_in(void);
@@ -185,14 +186,14 @@ setup(void)
} else {
#define OFLAGS \
(O_CREAT | (ddflags & (C_SEEK | C_NOTRUNC) ? 0 : O_TRUNC))
- out.fd = open(out.name, O_RDWR | OFLAGS /*, DEFFILEMODE */);
+ out.fd = open(out.name, O_RDWR | OFLAGS, DEFFILEMODE);
/*
* May not have read access, so try again with write only.
* Without read we may have a problem if output also does
* not support seeks.
*/
if (out.fd < 0) {
- out.fd = open(out.name, O_WRONLY | OFLAGS /*, DEFFILEMODE */);
+ out.fd = open(out.name, O_WRONLY | OFLAGS, DEFFILEMODE);
out.flags |= NOREAD;
}
if (out.fd < 0) {