diff --git a/itstar.c b/itstar.c index 3a9883a..99a3732 100644 --- a/itstar.c +++ b/itstar.c @@ -399,6 +399,14 @@ static void extfiles(int argc,char **argv) scantape(argc,argv,extfile); } +/* skip a single file */ +void skipfile() +{ + while (taperead() >= 0) + ; + taperead(); +} + /* extract a single file (called back by scantape()) */ static void extfile() { @@ -438,7 +446,6 @@ static void extfile() sprintf(lname,"%s/%s.%s",lufd,lfn1,lfn2); /* combine */ if(symlink(lname,fname)<0) { /* create link */ perror(fname); - exit(1); } /* can't apply dates since target may not exist */ taperead(); /* read the EOF mark */ @@ -454,7 +461,7 @@ static void extfile() else u.actime=u.modtime; /* use creation date if not */ if(utime(fname,&u)<0) { perror("?Error setting file dates"); - exit(1); + taperead(); /* read the EOF mark */ } } } @@ -542,9 +549,10 @@ static void scantape(int argc,char **argv,void (*process)()) while(taperead()==0) { /* read file label */ fhead: inword(&l,&r); /* 1: AOBJN ptr giving length */ len=01000000L-l; /* length of record */ - if(len<4) { /* must have at least filename */ - fprintf(stderr,"?Invalid tape format\n"); - exit(1); + if(len<4||len>10) { + fprintf(stderr,"?Invalid tape file header\n"); + skipfile(); + goto fhead; } insix(ufd); /* 2: UFD */ insix(fn1); /* 3: FN1 */ diff --git a/itstar.h b/itstar.h index 83b8a13..3842f1a 100644 --- a/itstar.h +++ b/itstar.h @@ -4,6 +4,7 @@ void save(char *f); void resetbuf(); void tapeflush(); int taperead(); +void skipfile(); void inword(long *l,long *r); void outword(register unsigned long l,register unsigned long r); int nextword(long *l,long *r); diff --git a/pack.c b/pack.c index d6482fc..1b3fed2 100644 --- a/pack.c +++ b/pack.c @@ -204,7 +204,8 @@ void pack(char *file) out=fopen(file,"wb"); /* create output file */ if(out==NULL) { perror(file); - exit(1); + skipfile(); + return; } if((remaining()==0)&&(taperead()<0)) {