From df4c9eab977217103184d91105f4b38ba956a06b Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Tue, 4 Jun 2013 03:34:19 +0200 Subject: [PATCH] trackfds.h: Fix invalid write if tracked_fds_count is 0. Also fixes missing initialization of env array. --- src/trackfds.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/trackfds.h b/src/trackfds.h index b26059d..07cfaa1 100644 --- a/src/trackfds.h +++ b/src/trackfds.h @@ -106,7 +106,9 @@ static void update_environment(void) { /* An integer (32-bit) has at most 10 digits, + 1 for the comma after each * number. Bigger file descriptors (which shouldn't occur in reality) are * skipped. */ - char env[tracked_fds_count * (10 + 1) * sizeof(char)]; + char env[tracked_fds_count * (10 + 1) + 1 /* to fit '\0' */ ]; + env[0] = 0; + char *x = env; size_t i; -- 2.45.2