]> granicus.if.org Git - procps-ng/commitdiff
0013-tload: Use snprintf() instead of sprintf().
authorQualys Security Advisory <qsa@qualys.com>
Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)
committerCraig Small <csmall@enc.com.au>
Sat, 23 Jun 2018 11:59:14 +0000 (21:59 +1000)
tload.c

diff --git a/tload.c b/tload.c
index 25b3425e4efaf37135a34d6e3c532d94982e5ded..9e99705a4f284a16d15c21ee85d37674738464bc 100644 (file)
--- a/tload.c
+++ b/tload.c
@@ -204,8 +204,8 @@ int main(int argc, char **argv)
                        for (row = nrows - 2; row >= 0; --row)
                                *(screen + row * ncols + col) = ' ';
                }
-               i = sprintf(screen, " %.2f, %.2f, %.2f", av[0], av[1], av[2]);
-               if (i > 0)
+               i = snprintf(screen, scr_size, " %.2f, %.2f, %.2f", av[0], av[1], av[2]);
+               if (i > 0 && i < scr_size)
                        screen[i] = ' ';
 
                if (write(fd, "\033[H", 3) < 0)