[dev] [sbase] [PATCH 2/4] tar: Support typeflag '\0' when extracting

From: Michael Forney <mforney_AT_mforney.org>
Date: Sat, 1 Nov 2014 20:36:38 +0000

POSIX recommends that "For backwards-compatibility, a typeflag value of
binary zero ( '\0' ) should be recognized as meaning a regular file when
extracting files from the archive".
---
 tar.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tar.c b/tar.c
index c18d89e..7bd709d 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -34,7 +34,7 @@ enum {
 };
 
 enum Type {
-	REG = '0', HARDLINK = '1', SYMLINK = '2', CHARDEV = '3',
+	REG = '0', AREG = '\0', HARDLINK = '1', SYMLINK = '2', CHARDEV = '3',
 	BLOCKDEV = '4', DIRECTORY = '5', FIFO = '6'
 };
 
_AT_@ -230,6 +230,7 @@ unarchive(char *fname, int l, char b[Blksiz])
 	unlink(fname);
 	switch(h->type) {
 	case REG:
+	case AREG:
 		mode = strtoul(h->mode, 0, 8);
 		if(!(f = fopen(fname, "w")) || chmod(fname, mode))
 			perror(fname);
-- 
2.1.3.1.g339ec9c
Received on Sat Nov 01 2014 - 21:36:38 CET

This archive was generated by hypermail 2.3.0 : Sat Nov 01 2014 - 21:48:13 CET