]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
userdbctl: initialize parameter `n` for uid_range_load_userns()
authorThomas Weißschuh <thomas@t-8ch.de>
Thu, 5 May 2022 23:06:08 +0000 (01:06 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 6 May 2022 04:48:51 +0000 (13:48 +0900)
uid_range_load_userns() dereferences the n parameter.

Passing unitialized memory may lead to crashes, for example with version
251rc2-1 on ArchLinux.

src/userdb/userdbctl.c

index b299bb8e11d8b88a67ac19ebef36230eb67d5777..9effb3c61ec287b1b6a05d5d7966899973bd2bff 100644 (file)
@@ -431,7 +431,7 @@ static int display_user(int argc, char *argv[], void *userdata) {
         if (table) {
                 _cleanup_free_ UidRange *uid_range = NULL;
                 int boundary_lines, uid_map_lines;
-                size_t n_uid_range;
+                size_t n_uid_range = 0;
 
                 r = uid_range_load_userns(&uid_range, &n_uid_range, "/proc/self/uid_map");
                 if (r < 0)
@@ -740,7 +740,7 @@ static int display_group(int argc, char *argv[], void *userdata) {
         if (table) {
                 _cleanup_free_ UidRange *gid_range = NULL;
                 int boundary_lines, gid_map_lines;
-                size_t n_gid_range;
+                size_t n_gid_range = 0;
 
                 r = uid_range_load_userns(&gid_range, &n_gid_range, "/proc/self/gid_map");
                 if (r < 0)