aboutsummaryrefslogtreecommitdiff
path: root/contrib/libarchive/tar/write.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/libarchive/tar/write.c')
-rw-r--r--contrib/libarchive/tar/write.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/contrib/libarchive/tar/write.c b/contrib/libarchive/tar/write.c
index 21984e980ebd..9e6c97b580b7 100644
--- a/contrib/libarchive/tar/write.c
+++ b/contrib/libarchive/tar/write.c
@@ -58,7 +58,7 @@
#endif
#include "bsdtar.h"
-#include "err.h"
+#include "lafe_err.h"
#include "line_reader.h"
#ifndef O_BINARY
@@ -111,7 +111,32 @@ seek_file(int fd, int64_t offset, int whence)
return (SetFilePointerEx((HANDLE)_get_osfhandle(fd),
distance, NULL, FILE_BEGIN) ? 1 : -1);
}
-#define open _open
+
+static int
+_open_wrap_sopen(char const *const path, int const oflag, ...)
+{
+ va_list ap;
+ int r, pmode;
+
+ pmode = 0;
+ if (oflag & _O_CREAT)
+ {
+ va_start(ap, oflag);
+ pmode = va_arg(ap, int);
+ va_end(ap);
+ }
+
+ _sopen_s(&r, path, oflag, _SH_DENYNO, pmode & 0600);
+ if (r < 0)
+ {
+ /* _sopen_s populates errno */
+ return -1;
+ }
+
+ return r;
+}
+
+#define open _open_wrap_sopen
#define close _close
#define read _read
#ifdef lseek