]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sysusers: log new group name on write failure
authorMikhail Nogin <joycap@altlinux.org>
Mon, 25 May 2026 13:33:43 +0000 (16:33 +0300)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 25 May 2026 17:21:50 +0000 (02:21 +0900)
When adding new groups, putgrent_with_members() is called with the newly
constructed group n, but the error path logs gr->gr_name. gr belongs to
the
earlier loop over the existing group file and may be NULL after EOF.

Log n.gr_name instead.

Found by Linux Verification Center (linuxtesting.org) with Svace.

src/sysusers/sysusers.c

index cdbc053f6b3d28a7597a16d2442bbc68359f3a70..c22dbbeda0236f4db944ece43cc4366e338175ff 100644 (file)
@@ -821,7 +821,7 @@ static int write_temporary_group(
                 r = putgrent_with_members(c, &n, group);
                 if (r < 0)
                         return log_error_errno(r, "Failed to add new group \"%s\" to temporary group file: %m",
-                                               gr->gr_name);
+                                               n.gr_name);
 
                 group_changed = true;
         }