]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_quota: Fix test for wrapped id from GETNEXTQUOTA
authorEric Sandeen <sandeen@redhat.com>
Thu, 22 Dec 2016 05:10:54 +0000 (23:10 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 22 Dec 2016 05:10:54 +0000 (23:10 -0600)
dump_file and report_mount can be called with null *oid if
we aren't asking for the GETNEXTQUOTA interface, so we
should only test for the GETNEXTQUOTA wrap if *oid is
non-null.  Otherwise we'll deref a null pointer in the
test.

This only happens for certain invocations of reporting,
which apparently are not covered by any regression tests
at this point, at least on new kernels which contain
GETNEXTQUOTA.

Addresses-Coverity-ID: 1397415
Addresses-Coverity-ID: 1397416
Brown-paper-bag-worn-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
quota/report.c

index fc023028f407fe0b365840fdc0f2b4c055bfa883..3833dd6e811b9d636ccd1b69ab7bd06749a5e7c0 100644 (file)
@@ -98,12 +98,12 @@ dump_file(
                return 0;
        }
 
-       if (oid)
+       if (oid) {
                *oid = d.d_id;
-
-       /* Did kernelspace wrap? */
-       if (*oid < id)
-               return 0;
+               /* Did kernelspace wrap? */
+               if (*oid < id)
+                       return 0;
+       }
 
        if (!d.d_blk_softlimit && !d.d_blk_hardlimit &&
            !d.d_ino_softlimit && !d.d_ino_hardlimit &&
@@ -361,12 +361,12 @@ report_mount(
                return 0;
        }
 
-       if (oid)
+       if (oid) {
                *oid = d.d_id;
-
-       /* Did kernelspace wrap? */
-       if (*oid < id)
-               return 0;
+               /* Did kernelspace wrap? */
+               if (* oid < id)
+                       return 0;
+       }
 
        if (flags & TERSE_FLAG) {
                count = 0;