]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfiles: fix borked assert
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 6 Jul 2021 14:41:28 +0000 (16:41 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 6 Jul 2021 19:05:00 +0000 (20:05 +0100)
It seems that fd_set_perms() is always called after checking that
fd >= 0 (also when called as action() in glob_item_recursively()),
so it seems that the assertion really came from fd==0.

Fixes #20140.

Also three other similar cases are updated.

src/tmpfiles/tmpfiles.c

index 9ffe7847958ecef21fc62d004dbf3b7e30075e94..7e85c506348a153b3a449109f0c6b3feb2b56a6e 100644 (file)
@@ -883,7 +883,7 @@ static int fd_set_perms(Item *i, int fd, const char *path, const struct stat *st
         int r;
 
         assert(i);
-        assert(fd);
+        assert(fd >= 0);
         assert(path);
 
         if (!i->mode_set && !i->uid_set && !i->gid_set)
@@ -1067,7 +1067,7 @@ static int fd_set_xattrs(Item *i, int fd, const char *path, const struct stat *s
         char **name, **value;
 
         assert(i);
-        assert(fd);
+        assert(fd >= 0);
         assert(path);
 
         xsprintf(procfs_path, "/proc/self/fd/%i", fd);
@@ -1170,7 +1170,7 @@ static int fd_set_acls(Item *item, int fd, const char *path, const struct stat *
         struct stat stbuf;
 
         assert(item);
-        assert(fd);
+        assert(fd >= 0);
         assert(path);
 
         if (!st) {
@@ -1324,7 +1324,7 @@ static int fd_set_attribute(Item *item, int fd, const char *path, const struct s
         int r;
 
         assert(item);
-        assert(fd);
+        assert(fd >= 0);
         assert(path);
 
         if (!item->attribute_set || item->attribute_mask == 0)