From 676d1948e590a9b0ff307497025193973feafabb Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Wed, 26 Jun 2002 21:45:46 +0000 Subject: [PATCH] Added archiver tests for gzip, compress, bzip --- ChangeLog | 1 + lib/unpacker.c | 28 ++++++++++++++++++++++------ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index abbedbfe..041bdee7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ v0.35.02 22-Jun-2002 common.a: Added debug nodelist IFT flag for logging. + Added archive detection for tar, gzip and compress. mbsetup: Changed node records layout into 8 screens to be able to add diff --git a/lib/unpacker.c b/lib/unpacker.c index f3023c15..6fced3b5 100644 --- a/lib/unpacker.c +++ b/lib/unpacker.c @@ -56,12 +56,28 @@ char *unpacker(char *fn) fclose(fp); - if (memcmp(buf,"PK",2) == 0) return (char *)"ZIP"; - if (*buf == 0x1a) return (char *)"ARC"; - if (memcmp(buf+2,"-l",2) == 0) return (char *)"LHA"; - if (memcmp(buf,"ZOO",3) == 0) return (char *)"ZOO"; - if (memcmp(buf,"`\352",2) == 0) return (char *)"ARJ"; - if (memcmp(buf,"Rar",3) == 0) return (char *)"RAR"; + if (memcmp(buf,"PK\003\004",4) == 0) return (char *)"ZIP"; + if (*buf == 0x1a) return (char *)"ARC"; + if (memcmp(buf+2,"-l",2) == 0) return (char *)"LHA"; + if (memcmp(buf,"ZOO",3) == 0) return (char *)"ZOO"; + if (memcmp(buf,"`\352",2) == 0) return (char *)"ARJ"; + if (memcmp(buf,"Rar!",4) == 0) return (char *)"RAR"; + if (memcmp(buf,"UC2\0x1a",4) == 0) return (char *)"UC2"; + if (memcmp(buf,"BZ",2) == 0) return (char *)"BZIP"; + if (memcmp(buf,"MSCF",4) == 0) return (char *)"CAB"; /* M$ CAB files */ + if (memcmp(buf,"\037\213",2) == 0) return (char *)"GZIP"; /* gzip compressed data */ + if (memcmp(buf,"\037\235",2) == 0) return (char *)"CMP"; /* unix compressed data */ + + if ((fp = fopen(fn,"r"))) { + fseek(fp, 257, SEEK_SET); + if (fread(buf,1,sizeof(buf),fp) != sizeof(buf)) { + WriteError("$Could not read position 257 of the file %s", fn); + fclose(fp); + return NULL; + } + fclose(fp); + } + if (memcmp(buf,"ustar",5) == 0) return (char *)"TAR"; /* GNU/Posix tar */ Syslog('p', "Unknown compress scheme in file %s", fn); return NULL;