Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f2b0a50 authored by Nick Kralevich's avatar Nick Kralevich
Browse files

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
parent 22aec573
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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) {