From: Simon Wilkinson Date: Tue, 26 Feb 2013 12:38:59 +0000 (+0000) Subject: volser: Catch EOFs when reading dumps X-Git-Tag: upstream/1.8.0_pre1^2~1406 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=cc703d9562455c74767fcd6d2055339109fa9243;p=packages%2Fo%2Fopenafs.git volser: Catch EOFs when reading dumps 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 Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Jeffrey Altman Tested-by: BuildBot --- diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index 3945d4483..ee4a79465 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -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;