diff options
author | Björn Baumbach <bb@sernet.de> | 2013-10-29 17:48:11 +0100 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2013-11-08 10:54:54 +0100 |
commit | 7fc2f97fb1dcd85aa1cad461fe611f844d7a3c62 (patch) | |
tree | dbe6ac1243f4e9532523d8370cc543656a7bad12 /lib | |
parent | 81e50485bb2e623ca06a6dc2996877ccc31120b0 (diff) | |
download | samba-7fc2f97fb1dcd85aa1cad461fe611f844d7a3c62.tar.gz |
CVE-2013-4476: lib-util: split out file_save_mode() from file_save()
file_save_mode() writes files with specified mode.
Bug: https://bugzilla.samba.org/show_bug.cgi?id=10234
Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/util/samba_util.h | 2 | ||||
-rw-r--r-- | lib/util/util_file.c | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h index f98cf6066a3..243ed3e50da 100644 --- a/lib/util/samba_util.h +++ b/lib/util/samba_util.h @@ -580,6 +580,8 @@ a line **/ _PUBLIC_ void file_lines_slashcont(char **lines); +_PUBLIC_ bool file_save_mode(const char *fname, const void *packet, + size_t length, mode_t mode); /** save a lump of data into a file. Mostly used for debugging */ diff --git a/lib/util/util_file.c b/lib/util/util_file.c index e031fc51122..815cc2bf9e6 100644 --- a/lib/util/util_file.c +++ b/lib/util/util_file.c @@ -368,13 +368,11 @@ _PUBLIC_ void file_lines_slashcont(char **lines) } } -/** - save a lump of data into a file. Mostly used for debugging -*/ -_PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length) +_PUBLIC_ bool file_save_mode(const char *fname, const void *packet, + size_t length, mode_t mode) { int fd; - fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0644); + fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC, mode); if (fd == -1) { return false; } @@ -386,6 +384,14 @@ _PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length) return true; } +/** + save a lump of data into a file. Mostly used for debugging +*/ +_PUBLIC_ bool file_save(const char *fname, const void *packet, size_t length) +{ + return file_save_mode(fname, packet, length, 0644); +} + _PUBLIC_ int vfdprintf(int fd, const char *format, va_list ap) { char *p; |