diff options
| author | Eli Zaretskii | 2008-12-05 16:49:20 +0000 |
|---|---|---|
| committer | Eli Zaretskii | 2008-12-05 16:49:20 +0000 |
| commit | b5ec91a5c0c59a6c4f296af4716b4409e5988a53 (patch) | |
| tree | a74983a99eb06c8d28e22a5645dd96a33c58c279 /src/process.c | |
| parent | b3f1f4a52de85d544be96acce97d7c8571f770c5 (diff) | |
| download | emacs-b5ec91a5c0c59a6c4f296af4716b4409e5988a53.tar.gz emacs-b5ec91a5c0c59a6c4f296af4716b4409e5988a53.zip | |
(procfs_system_process_attributes): If `nread' has a negative value, assign
zero to it.
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/process.c b/src/process.c index b5d2f3d4c9f..5084bc8d159 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -7434,6 +7434,14 @@ procfs_system_process_attributes (pid) | |||
| 7434 | cmdline[0] = '\0'; | 7434 | cmdline[0] = '\0'; |
| 7435 | if ((nread = read (fd, cmdline, cmdline_size)) >= 0) | 7435 | if ((nread = read (fd, cmdline, cmdline_size)) >= 0) |
| 7436 | cmdline[nread++] = '\0'; | 7436 | cmdline[nread++] = '\0'; |
| 7437 | else | ||
| 7438 | { | ||
| 7439 | /* Assigning zero to `nread' makes us skip the following | ||
| 7440 | two loops, assign zero to cmdline_size, and enter the | ||
| 7441 | following `if' clause that handles unknown command | ||
| 7442 | lines. */ | ||
| 7443 | nread = 0; | ||
| 7444 | } | ||
| 7437 | /* We don't want trailing null characters. */ | 7445 | /* We don't want trailing null characters. */ |
| 7438 | for (p = cmdline + nread - 1; p > cmdline && !*p; p--) | 7446 | for (p = cmdline + nread - 1; p > cmdline && !*p; p--) |
| 7439 | nread--; | 7447 | nread--; |
| @@ -7451,7 +7459,7 @@ procfs_system_process_attributes (pid) | |||
| 7451 | } | 7459 | } |
| 7452 | cmdline_size = nread; | 7460 | cmdline_size = nread; |
| 7453 | } | 7461 | } |
| 7454 | else | 7462 | if (!cmdline_size) |
| 7455 | { | 7463 | { |
| 7456 | if (!cmd) | 7464 | if (!cmd) |
| 7457 | cmd = "???"; | 7465 | cmd = "???"; |