diff options
author | Andreas Schneider <asn@samba.org> | 2017-08-01 10:58:50 +0200 |
---|---|---|
committer | Andreas Schneider <asn@samba.org> | 2017-09-07 07:57:22 +0200 |
commit | 753f3872370a076628c272612da51963f4996ca4 (patch) | |
tree | d36ccc7b55677b09e1d45b4c2dc0c50c7309da8c /src | |
parent | 03c06022e29e790938a1701a686ee2863677ff3c (diff) | |
download | socket_wrapper-753f3872370a076628c272612da51963f4996ca4.tar.gz socket_wrapper-753f3872370a076628c272612da51963f4996ca4.tar.xz socket_wrapper-753f3872370a076628c272612da51963f4996ca4.zip |
swrap: Improve argument handling for libc_vopen*()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/socket_wrapper.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/socket_wrapper.c b/src/socket_wrapper.c index 0a7dacf..d95dbc0 100644 --- a/src/socket_wrapper.c +++ b/src/socket_wrapper.c @@ -859,13 +859,14 @@ static FILE *libc_fopen64(const char *name, const char *mode) static int libc_vopen(const char *pathname, int flags, va_list ap) { - long int mode = 0; + int mode = 0; int fd; swrap_bind_symbol_libc(open); - mode = va_arg(ap, long int); - + if (flags & O_CREAT) { + mode = va_arg(ap, int); + } fd = swrap.libc.symbols._libc_open.f(pathname, flags, (mode_t)mode); return fd; @@ -886,13 +887,14 @@ static int libc_open(const char *pathname, int flags, ...) #ifdef HAVE_OPEN64 static int libc_vopen64(const char *pathname, int flags, va_list ap) { - long int mode = 0; + int mode = 0; int fd; swrap_bind_symbol_libc(open64); - mode = va_arg(ap, long int); - + if (flags & O_CREAT) { + mode = va_arg(ap, int); + } fd = swrap.libc.symbols._libc_open64.f(pathname, flags, (mode_t)mode); return fd; @@ -901,14 +903,18 @@ static int libc_vopen64(const char *pathname, int flags, va_list ap) static int libc_vopenat(int dirfd, const char *path, int flags, va_list ap) { - long int mode = 0; + int mode = 0; int fd; swrap_bind_symbol_libc(openat); - mode = va_arg(ap, long int); - - fd = swrap.libc.symbols._libc_openat.f(dirfd, path, flags, (mode_t)mode); + if (flags & O_CREAT) { + mode = va_arg(ap, int); + } + fd = swrap.libc.symbols._libc_openat.f(dirfd, + path, + flags, + (mode_t)mode); return fd; } |