]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/idmapping.c: write_mapping(): Fixx off-by-one bug
authorAlejandro Colomar <alx@kernel.org>
Thu, 11 Jan 2024 18:12:24 +0000 (19:12 +0100)
committerSerge Hallyn <serge@hallyn.com>
Mon, 15 Jan 2024 19:37:09 +0000 (13:37 -0600)
Link: <https://github.com/shadow-maint/shadow/commit/673c2a6f9aa6c69588f4c1be08589b8d3475a520#r136830993>
Cc: Serge Hallyn <serge@hallyn.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/idmapping.c

index 7454c3d818bc6fc4c2e0429716a3c2bf10217535..c861beb6502fafdd6f800adc67e81581c879523a 100644 (file)
@@ -192,7 +192,7 @@ void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings
        }
 #endif
 
-       bufsize = ranges * ((ULONG_DIGITS + 1) * 3);
+       bufsize = (ULONG_DIGITS + 1) * 3 * ranges + 1;
        pos = buf = XMALLOC(bufsize, char);
        end = buf + bufsize;