]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Improve error handling when vgdb cannot read process cmd line
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Tue, 15 Jan 2013 23:09:41 +0000 (23:09 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Tue, 15 Jan 2013 23:09:41 +0000 (23:09 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13233

coregrind/vgdb.c

index 4b2b0afb7cc98889b604e772394504b2ab2b5bbc..b46c4b9d54f163bc87c9ac51d464b5a795b5a84d 100644 (file)
@@ -2014,13 +2014,19 @@ void report_pid (int pid, Bool on_stdout)
    if (fd == -1) {
       DEBUG(1, "error opening cmdline file %s %s\n", 
             cmdline_file, strerror(errno));
-      sprintf(cmdline, "(could not obtain process command line)");
+      sprintf(cmdline, "(could not open process command line)");
    } else {
       sz = read(fd, cmdline, 1000);
       for (i = 0; i < sz; i++)
          if (cmdline[i] == 0)
             cmdline[i] = ' ';
-      cmdline[sz] = 0;
+      if (sz >= 0)
+         cmdline[sz] = 0;
+      else {
+         DEBUG(1, "error reading cmdline file %s %s\n", 
+               cmdline_file, strerror(errno));
+         sprintf(cmdline, "(could not read process command line)");
+      }
       close (fd);
    }  
    fprintf((on_stdout ? stdout : stderr), "use --pid=%d for %s\n", pid, cmdline);