From: Stelian Pop Date: Thu, 17 Jun 2004 09:01:13 +0000 (+0000) Subject: Fix SIGSEGV when reading a hand-modified dumpdates file. X-Git-Tag: release_0_4b38~17 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=1f2c193ec243b3c8ea7865c59381f2321afb98f8;p=dump.git Fix SIGSEGV when reading a hand-modified dumpdates file. --- diff --git a/CHANGES b/CHANGES index 83cad50..cc9eb64 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.249 2004/06/02 09:22:48 stelian Exp $ +$Id: CHANGES,v 1.250 2004/06/17 09:01:13 stelian Exp $ Changes between versions 0.4b36 and 0.4b37 (released ??????????????) ==================================================================== @@ -17,6 +17,10 @@ Changes between versions 0.4b36 and 0.4b37 (released ??????????????) that are also defined by () and they conflict). +3. Make dump's reading of the dumpdates file a bit more robust, + preventing dump from crashing when the dumpdates file has + been modified by hand. + Changes between versions 0.4b35 and 0.4b36 (released April 21, 2004) ==================================================================== diff --git a/dump/itime.c b/dump/itime.c index 6ea6ef9..f2cc763 100644 --- a/dump/itime.c +++ b/dump/itime.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: itime.c,v 1.27 2004/04/21 08:55:51 stelian Exp $"; + "$Id: itime.c,v 1.28 2004/06/17 09:01:15 stelian Exp $"; #endif /* not lint */ #include @@ -283,9 +283,11 @@ getrecord(FILE *df, struct dumpdates *ddatep) if (fgets(tbuf, sizeof (tbuf), df) == NULL) return(-1); recno++; - if (makedumpdate(ddatep, tbuf) < 0) - msg("Unknown intermediate format in %s, line %d\n", + if (makedumpdate(ddatep, tbuf) < 0) { + msg("Unknown format in %s, line %d\n", dumpdates, recno); + return(-1); + } #ifdef FDEBUG msg("getrecord: %s %d %s", ddatep->dd_name, ddatep->dd_level, @@ -301,7 +303,7 @@ makedumpdate(struct dumpdates *ddp, char *tbuf) /* device name */ if ( NULL == (tok = strsep( &tbuf, " ")) ) return(-1); - if ( strlen(tok) > MAXPATHLEN ) + if ( !tbuf || strlen(tok) > MAXPATHLEN ) return(-1); strcpy(ddp->dd_name, tok);