[PATCH 1/2] tar: extract creation mode

From: Brad Barden <brad_AT_13os.net>
Date: Wed, 18 Nov 2015 20:49:07 -0600

mode for newly-created files should be restrictive. chmod is always
called soon after to set correct mode from the archive.
---
 tar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tar.c b/tar.c
index 1943e18..de58247 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -270,7 +270,7 @@ unarchive(char *fname, ssize_t l, char b[BLKSIZ])
 	case RESERVED:
 		if ((mode = strtol(h->mode, &p, 8)) < 0 || *p != '\0')
 			eprintf("strtol %s: invalid number\n", h->mode);
-		fd = open(fname, O_WRONLY | O_TRUNC | O_CREAT, 0644);
+		fd = open(fname, O_WRONLY | O_TRUNC | O_CREAT, 0600);
 		if (fd < 0)
 			eprintf("open %s:", fname);
 		if (fchmod(fd, mode) < 0)
-- 
2.3.6
--PEIAKu/WMn1b1Hv9
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment; filename="0002-tar-improve-file-status-handling-on-extract.patch"
Received on Mon Sep 17 2001 - 00:00:00 CEST

This archive was generated by hypermail 2.3.0 : Thu Nov 19 2015 - 10:00:11 CET