volser: Catch EOFs when reading dumps
authorSimon Wilkinson <sxw@your-file-system.com>
Tue, 26 Feb 2013 12:38:59 +0000 (12:38 +0000)
committerJeffrey Altman <jaltman@your-file-system.com>
Wed, 27 Feb 2013 01:19:49 +0000 (17:19 -0800)
When reading a standard tag, make sure and catch an EOF error
from iod_getc. Otherwise we'll end up trying to parse 0xFF as a
tag length.

Caught by coverity (#985603)

Change-Id: Iae0b1bf71ed495b4f454975a1bfe3aef8fca3e9e
Reviewed-on: http://gerrit.openafs.org/9275
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/volser/dumpstuff.c

index 3945d44..ee4a794 100644 (file)
@@ -281,7 +281,8 @@ ReadStandardTagLen(struct iod *iodp, unsigned char tag, afs_int32 section,
     afs_int32 code, i;
     afs_uint32 off = tag >> 5;
     afs_uint32 mask = 1 << (tag & 0x1f);
-    unsigned char len, buf[8], *p;
+    int len;
+    unsigned char buf[8], *p;
 
     if (!oldtagsInited)
         initNonStandardTags();
@@ -295,7 +296,9 @@ ReadStandardTagLen(struct iod *iodp, unsigned char tag, afs_int32 section,
     }
     if (tag <= MAX_TLV_TAG) {
         len = iod_getc(iodp);
-        if (len < 128)
+       if (len == EOF)
+           return VOLSERDUMPERROR;
+       else if (len < 128)
             *length = len;
         else {
             len &= 0x7f;