From: Michael Meffie Date: Fri, 30 Jan 2015 17:20:10 +0000 (-0500) Subject: volser: detect eof in dump stream while reading acl X-Git-Tag: upstream/1.6.18^2~19 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e980a39cc39a02de8e112323f6037c740ee60728;p=packages%2Fo%2Fopenafs.git volser: detect eof in dump stream while reading acl Detect an EOF condition while reading the ACL in a dump stream and return a restore error, instead of filling the ACL with 0xFF and then failing the restore due to an invalid tag. Reviewed-on: http://gerrit.openafs.org/11703 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot (cherry picked from commit ed52d65fe98549e13023e0a8997da479b626085a) Change-Id: I9aacd635b8bbf89923db0121639d5112ab775c19 Reviewed-on: https://gerrit.openafs.org/12185 Reviewed-by: Mark Vitale Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index b37301d37..d3e1e0a99 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -274,12 +274,17 @@ ReadString(struct iod *iodp, char *to, int maxa) } } -static void -ReadByteString(struct iod *iodp, byte * to, - int size) +static int +ReadByteString(struct iod *iodp, byte * to, int size) { - while (size--) - *to++ = iod_getc(iodp); + int nbytes = 0; + int c; + + while (size-- > 0 && (c = iod_getc(iodp)) != EOF) { + *to++ = c; + nbytes++; + } + return nbytes; } /* @@ -1357,6 +1362,7 @@ ReadVnodes(struct iod *iodp, Volume * vp, int incremental, FdHandle_t *fdP; Inode nearInode AFS_UNUSED; afs_int32 critical = 0; + int nbytes; tag = iod_getc(iodp); V_pref(vp, nearInode); @@ -1422,8 +1428,13 @@ ReadVnodes(struct iod *iodp, Volume * vp, int incremental, return VOLSERREAD_DUMPERROR; break; case 'A': - ReadByteString(iodp, (byte *) VVnodeDiskACL(vnode), + nbytes = ReadByteString(iodp, (byte *) VVnodeDiskACL(vnode), VAclDiskSize(vnode)); + if (nbytes != VAclDiskSize(vnode)) { + Log("ReadVnodes: could not read acl for vnode %lu in dump.\n", + (unsigned long)vnodeNumber); + return VOLSERREAD_DUMPERROR; + } if (acl_NtohACL(VVnodeDiskACL(vnode)) != 0) { Log("ReadVnodes: invalid acl for vnode %lu in dump.\n", (unsigned long)vnodeNumber);