]> granicus.if.org Git - procps-ng/commitdiff
0047-proc/whattime.c: Always initialize buf.
authorQualys Security Advisory <qsa@qualys.com>
Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)
committerCraig Small <csmall@enc.com.au>
Sat, 9 Jun 2018 11:35:19 +0000 (21:35 +1000)
In the human_readable case; otherwise the strcat() that follows may
append bytes to the previous contents of buf.

Also, slightly enlarge buf, as it was a bit too tight.

Could also replace all sprintf()s with snprintf()s, but all the calls
here output a limited number of characters, so they should be safe.

---------------------------- adapted for newlib branch
. the source file is now proc/uptime.c
. function is now named 'procps_uptime_sprint()'
. new human readable function 'procps_uptime_sprint_short()'
. both were already initialized, so just raised size of 2 buffers

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/uptime.c

index d264d4ba977afbdf8484a21d6e758c8bd1090e28..fc714d8e8b58a849af508bd7c3a311e7bb5bb570 100644 (file)
@@ -37,8 +37,8 @@
 
 #define UPTIME_FILE "/proc/uptime"
 
-static __thread char upbuf[128];
-static __thread char shortbuf[128];
+static __thread char upbuf[256];
+static __thread char shortbuf[256];
 
 static int count_users(void)
 {