butc: don't pass NULL to strcpy in RcreateDump
authorGarrett Wollman <wollman@csail.mit.edu>
Fri, 27 Jul 2012 23:50:42 +0000 (19:50 -0400)
committerDerrick Brashear <shadow@dementix.org>
Sat, 28 Jul 2012 03:19:52 +0000 (20:19 -0700)
volumesetNamePtr can return a null pointer in certain error
conditions.  Check for this and return BUDB_BADARGUMENT rather
than dumping core.

Change-Id: If0ce509c964211ffa591d8e095b7c32c51ae7bc3
Reviewed-on: http://gerrit.openafs.org/7890
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/butc/recoverDb.c

index 7bc6f7d..b1f5c90 100644 (file)
@@ -906,6 +906,7 @@ RcreateDump(struct tapeScanInfo *tapeScanInfoPtr,
            struct volumeHeader *volHeaderPtr)
 {
     afs_int32 code;
+    const char *volsetName;
     struct butm_tapeLabel *dumpLabelPtr = &tapeScanInfoPtr->dumpLabel;
     struct budb_dumpEntry *dumpEntryPtr = &tapeScanInfoPtr->dumpEntry;
 
@@ -919,8 +920,10 @@ RcreateDump(struct tapeScanInfo *tapeScanInfoPtr,
     dumpEntryPtr->flags = 0;
     dumpEntryPtr->incTime = 0;
     dumpEntryPtr->nVolumes = 0;
-    strcpy(dumpEntryPtr->volumeSetName,
-          volumesetNamePtr(volHeaderPtr->dumpSetName));
+    volsetName = volumesetNamePtr(volHeaderPtr->dumpSetName);
+    if (volsetName == NULL)
+       return BUDB_BADARGUMENT;
+    strcpy(dumpEntryPtr->volumeSetName, volsetName);
     strcpy(dumpEntryPtr->dumpPath, dumpLabelPtr->dumpPath);
     strcpy(dumpEntryPtr->name, volHeaderPtr->dumpSetName);
     default_tapeset(&dumpEntryPtr->tapes, volHeaderPtr->dumpSetName);