summaryrefslogtreecommitdiff
path: root/lib/util/util_file.c
diff options
context:
space:
mode:
authorBjörn Baumbach <bb@sernet.de>2013-10-29 17:48:11 +0100
committerKarolin Seeger <kseeger@samba.org>2013-11-11 11:14:36 +0100
commit63d98ed90466295d0e946f79868d3d7aad6e7589 (patch)
tree23d6460d7383ba408c00e99d8fb71286b44d4c34 /lib/util/util_file.c
parent8eae8d28bce2c3f6a323d3dc48ed10c2e6bb1ba5 (diff)
downloadsamba-63d98ed90466295d0e946f79868d3d7aad6e7589.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/util/util_file.c')
-rw-r--r--lib/util/util_file.c16
1 files changed, 11 insertions, 5 deletions
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;