diff options
author | Rich Felker <dalias@aerifal.cx> | 2014-10-30 20:08:40 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2014-10-30 20:11:04 -0400 |
commit | 2da3ab1382ca8e39eb1e4428103764a81fba73d3 (patch) | |
tree | 366d0775bb4976aad0dd6110a2d71c576290785a /src/fcntl/openat.c | |
parent | 9d836ea7a69a6441fcdca815328d274e4ed6b707 (diff) | |
download | musl-2da3ab1382ca8e39eb1e4428103764a81fba73d3.tar.gz musl-2da3ab1382ca8e39eb1e4428103764a81fba73d3.tar.bz2 musl-2da3ab1382ca8e39eb1e4428103764a81fba73d3.tar.xz musl-2da3ab1382ca8e39eb1e4428103764a81fba73d3.zip |
fix invalid access by openat to possibly-missing variadic mode argument
the mode argument is only required to be present when the O_CREAT or
O_TMPFILE flag is used.
Diffstat (limited to 'src/fcntl/openat.c')
-rw-r--r-- | src/fcntl/openat.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/fcntl/openat.c b/src/fcntl/openat.c index 634c4bf3..4faeb296 100644 --- a/src/fcntl/openat.c +++ b/src/fcntl/openat.c @@ -6,10 +6,14 @@ int openat(int fd, const char *filename, int flags, ...) { mode_t mode; - va_list ap; - va_start(ap, flags); - mode = va_arg(ap, mode_t); - va_end(ap); + + if ((flags & O_CREAT) || (flags & O_TMPFILE) == O_TMPFILE) { + va_list ap; + va_start(ap, flags); + mode = va_arg(ap, mode_t); + va_end(ap); + } + return syscall_cp(SYS_openat, fd, filename, flags|O_LARGEFILE, mode); } |