From: Simon Ruderich Date: Tue, 4 Jun 2013 01:34:19 +0000 (+0200) Subject: trackfds.h: Fix invalid write if tracked_fds_count is 0. X-Git-Tag: 0.1~115 X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=df4c9eab977217103184d91105f4b38ba956a06b;p=coloredstderr%2Fcoloredstderr.git trackfds.h: Fix invalid write if tracked_fds_count is 0. Also fixes missing initialization of env array. --- 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;