tar: Support typeflag '\0' when extracting
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".
This commit is contained in:
parent
453ce96d44
commit
0e8a8c9426
3
tar.c
3
tar.c
|
@ -34,7 +34,7 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Type {
|
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'
|
BLOCKDEV = '4', DIRECTORY = '5', FIFO = '6'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -230,6 +230,7 @@ unarchive(char *fname, int l, char b[Blksiz])
|
||||||
unlink(fname);
|
unlink(fname);
|
||||||
switch(h->type) {
|
switch(h->type) {
|
||||||
case REG:
|
case REG:
|
||||||
|
case AREG:
|
||||||
mode = strtoul(h->mode, 0, 8);
|
mode = strtoul(h->mode, 0, 8);
|
||||||
if(!(f = fopen(fname, "w")) || chmod(fname, mode))
|
if(!(f = fopen(fname, "w")) || chmod(fname, mode))
|
||||||
perror(fname);
|
perror(fname);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user