]> git.wh0rd.org - dump.git/commitdiff
Fix SIGSEGV when reading a hand-modified dumpdates file.
authorStelian Pop <stelian@popies.net>
Thu, 17 Jun 2004 09:01:13 +0000 (09:01 +0000)
committerStelian Pop <stelian@popies.net>
Thu, 17 Jun 2004 09:01:13 +0000 (09:01 +0000)
CHANGES
dump/itime.c

diff --git a/CHANGES b/CHANGES
index 83cad506e89141b2cd1a27d9ea3b6d07f4f15725..cc9eb64eb7eb06e3cde0f0033f1c16ae2884cf4f 100644 (file)
--- 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 <linux/types.h> (<asm/types.h>) 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)
 ====================================================================
 
index 6ea6ef91abb375e8efe433525d03441286f1428a..f2cc76307eaf68d3e15b6569fc5760ba76598864 100644 (file)
@@ -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 <config.h>
@@ -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);