--- tar.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/tar.c b/tar.c index 1ecf8bd..dc82888 100644 --- a/tar.c +++ b/tar.c _AT_@ -166,6 +166,13 @@ archive(const char* path) fprintf(stderr, "ignoring '%s'\n", path); return 0; } + mode = st.st_mode; + /* return early for character and block devices */ + if(S_ISCHR(mode) || S_ISBLK(mode)) { + weprintf("ignoring character or block device\n"); + return 0; + } + pw = getpwuid(st.st_uid); gr = getgrgid(st.st_gid); _AT_@ -191,10 +198,6 @@ archive(const char* path) } else if(S_ISLNK(mode)) { h->type = SYMLINK; readlink(path, h->link, (sizeof h->link)-1); - } else if(S_ISCHR(mode) || S_ISBLK(mode)) { - h->type = S_ISCHR(mode) ? CHARDEV : BLOCKDEV; - putoctal(h->major, (unsigned)major(st.st_dev), sizeof h->major); - putoctal(h->minor, (unsigned)minor(st.st_dev), sizeof h->minor); } else if(S_ISFIFO(mode)) { h->type = FIFO; } _AT_@ -221,7 +224,7 @@ unarchive(char *fname, int l, char b[Blksiz]) { char lname[101]; FILE *f = NULL; - unsigned long mode, major, minor, type; + unsigned long mode; Header *h = (void*)b; unlink(fname); _AT_@ -244,15 +247,8 @@ unarchive(char *fname, int l, char b[Blksiz]) break; case CHARDEV: case BLOCKDEV: -#ifdef makedev - mode = strtoul(h->mode, 0, 8); - major = strtoul(h->major, 0, 8); - minor = strtoul(h->mode, 0, 8); - type = (h->type == CHARDEV) ? S_IFCHR : S_IFBLK; - if(mknod(fname, type | mode, makedev(major, minor))) - perror(fname); -#endif - break; + weprintf("ignoring character or block device\n"); + goto out; case FIFO: mode = strtoul(h->mode, 0, 8); if(mknod(fname, S_IFIFO | mode, 0)) _AT_@ -265,6 +261,7 @@ unarchive(char *fname, int l, char b[Blksiz]) strtoul(h->gid, 0, 8))) perror(fname); +out: for(; l > 0; l -= Blksiz) { fread(b, Blksiz, 1, tarfile); if(f) -- 1.8.5.3 --MGYHOYXEY6WxJCY8--Received on Mon Sep 17 2001 - 00:00:00 CEST
This archive was generated by hypermail 2.3.0 : Thu Jan 30 2014 - 16:48:03 CET