]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
volser: detect eof in dump stream while reading acl
authorMichael Meffie <mmeffie@sinenomine.net>
Fri, 30 Jan 2015 17:20:10 +0000 (12:20 -0500)
committerStephan Wiesand <stephan.wiesand@desy.de>
Thu, 31 Mar 2016 09:18:57 +0000 (05:18 -0400)
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 <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit ed52d65fe98549e13023e0a8997da479b626085a)

Change-Id: I9aacd635b8bbf89923db0121639d5112ab775c19
Reviewed-on: https://gerrit.openafs.org/12185
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/volser/dumpstuff.c

index b37301d37bdbef05a66c4d7b5c44d4cb57a8cc29..d3e1e0a9994ad66d75afd23ff45110005007ece5 100644 (file)
@@ -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);