diff options
author | Nick Kralevich <nnk@google.com> | 2012-06-26 15:01:03 -0700 |
---|---|---|
committer | Koushik Dutta <koushd@gmail.com> | 2012-11-24 17:01:08 -0800 |
commit | 456610476df77a61bec4336a1348992993e6aa0a (patch) | |
tree | a1d42943ab1c1d7b98e4d90aaed7de426e27fee6 | |
parent | 20cdd24854d773e197a346d80a8d65357258000e (diff) | |
download | bootable_recovery-456610476df77a61bec4336a1348992993e6aa0a.zip bootable_recovery-456610476df77a61bec4336a1348992993e6aa0a.tar.gz bootable_recovery-456610476df77a61bec4336a1348992993e6aa0a.tar.bz2 |
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 compile error in a future Android change.
Change-Id: I73c1e1a39ca36bf01704b07302af4971d234b5a8
-rw-r--r-- | applypatch/applypatch.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 00004e9..488fd8c 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -324,7 +324,7 @@ static int LoadPartitionContents(const char* filename, FileContents* file) { // Save the contents of the given FileContents object under the given // filename. Return 0 on success. int SaveFileContents(const char* filename, const FileContents* file) { - int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC); + int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (fd < 0) { printf("failed to open \"%s\" for write: %s\n", filename, strerror(errno)); @@ -843,7 +843,7 @@ static int GenerateTarget(FileContents* source_file, strcpy(outname, target_filename); strcat(outname, ".patch"); - output = open(outname, O_WRONLY | O_CREAT | O_TRUNC); + output = open(outname, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (output < 0) { printf("failed to open output file %s: %s\n", outname, strerror(errno)); |