]> arthur.barton.de Git - bup.git/commitdiff
Assume FS_IOC_GETFLAGS may trash output on error
authorMark J Hewitt <m.hewitt@computer.org>
Mon, 11 Aug 2014 10:36:19 +0000 (11:36 +0100)
committerRob Browning <rlb@defaultvalue.org>
Mon, 11 Aug 2014 17:53:00 +0000 (12:53 -0500)
Don't assert that the attr value is reasonable (<= UINT_MAX) when
FS_IOC_GETFLAGS returns an error, because it may change the the value
to something invalid in that situation.

This has been observed to occur when, for example, the underlying
filesystem does not support the operation,

Signed-off-by: Mark J Hewitt <m.hewitt@computer.org>
[rlb@defaultvalue.org: adjust commit message]
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/_helpers.c

index 65a8b6bafa8ef51efeab07c5d8cf7febb7b0787e..9082dca72994079da1f900f8785f751a3d52715c 100644 (file)
@@ -842,14 +842,13 @@ static PyObject *bup_get_linux_file_attr(PyObject *self, PyObject *args)
 
     attr = 0;  // Handle int/long mismatch (see above)
     rc = ioctl(fd, FS_IOC_GETFLAGS, &attr);
-    assert(attr <= UINT_MAX);  // Kernel type is actually int
     if (rc == -1)
     {
         close(fd);
         return PyErr_SetFromErrnoWithFilename(PyExc_OSError, path);
     }
-
     close(fd);
+    assert(attr <= UINT_MAX);  // Kernel type is actually int
     return PyLong_FromUnsignedLong(attr);
 }
 #endif /* def BUP_HAVE_FILE_ATTRS */