]> arthur.barton.de Git - bup.git/commitdiff
Check attr value *after* ensuring call succeeded
authorRob Browning <rlb@defaultvalue.org>
Wed, 7 Sep 2016 04:35:28 +0000 (23:35 -0500)
committerRob Browning <rlb@defaultvalue.org>
Wed, 7 Sep 2016 04:43:17 +0000 (23:43 -0500)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/_helpers.c

index c77692ab7e514e489e6f2665afba2b26336afcf0..8085cfc4b2ea3aeb9091a409cdfd3e265571bf17 100644 (file)
@@ -1137,12 +1137,12 @@ static PyObject *bup_set_linux_file_attr(PyObject *self, PyObject *args)
     // The extents flag can't be removed, so don't (see chattr(1) and chattr.c).
     orig_attr = 0; // Handle int/long mismatch (see above)
     rc = ioctl(fd, FS_IOC_GETFLAGS, &orig_attr);
-    assert(orig_attr <= UINT_MAX);  // Kernel type is actually int
     if (rc == -1)
     {
         close(fd);
         return PyErr_SetFromErrnoWithFilename(PyExc_OSError, path);
     }
+    assert(orig_attr <= UINT_MAX);  // Kernel type is actually int
     attr |= ((unsigned int) orig_attr) & FS_EXTENT_FL;
 
     rc = ioctl(fd, FS_IOC_SETFLAGS, &attr);