From 1bbf030846670d022d84b475f86d8e859ddaf903 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Tue, 6 Sep 2016 23:35:28 -0500 Subject: [PATCH] Check attr value *after* ensuring call succeeded Signed-off-by: Rob Browning Tested-by: Rob Browning --- lib/bup/_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/bup/_helpers.c b/lib/bup/_helpers.c index c77692a..8085cfc 100644 --- a/lib/bup/_helpers.c +++ b/lib/bup/_helpers.c @@ -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); -- 2.39.2