|
From: Mark W. <ma...@so...> - 2019-05-25 14:29:01
|
https://sourceware.org/git/gitweb.cgi?p=valgrind.git;h=f7f48f91b046751def38326f8a8547bb8c98d4f2 commit f7f48f91b046751def38326f8a8547bb8c98d4f2 Author: Mark Wielaard <ma...@kl...> Date: Sat May 25 16:25:19 2019 +0200 vgdb: Fix read check in report_pid. When read fails it will return -1. In which case we might assign cmdline[sz] = 0 and print a garbage cmdline. Fix the test to check the return value is > 0. Diff: --- coregrind/vgdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coregrind/vgdb.c b/coregrind/vgdb.c index 075c737..e678eac 100644 --- a/coregrind/vgdb.c +++ b/coregrind/vgdb.c @@ -1090,7 +1090,7 @@ void report_pid(int pid, Bool on_stdout) } else { char cmdline[100]; ssize_t sz; - while ((sz = read(fd, cmdline, sizeof cmdline - 1)) != 0) { + while ((sz = read(fd, cmdline, sizeof cmdline - 1)) > 0) { for (i = 0; i < sz; i++) if (cmdline[i] == 0) cmdline[i] = ' '; |