From 77249c3a549865565b15456cd511a690f127d163 Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Tue, 26 Feb 2013 12:38:59 +0000 Subject: [PATCH] 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) Reviewed-on: http://gerrit.openafs.org/9275 Reviewed-by: Derrick Brashear Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Jeffrey Altman Tested-by: BuildBot (cherry picked from commit cc703d9562455c74767fcd6d2055339109fa9243) Change-Id: I29957f7b656bb2cdd19601d90990d7bacd82e98c Reviewed-on: http://gerrit.openafs.org/9361 Tested-by: BuildBot Reviewed-by: Derrick Brashear Reviewed-by: Paul Smeddle Reviewed-by: Benjamin Kaduk Reviewed-by: Andrew Deason Reviewed-by: Stephan Wiesand --- src/volser/dumpstuff.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index 53aa8b8d0..0e1213ad9 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -291,7 +291,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(); @@ -305,7 +306,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; -- 2.39.5