summaryrefslogtreecommitdiff
path: root/pwdx.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@ubuntu.com>2013-08-05 20:52:22 +1000
committerCraig Small <csmall@enc.com.au>2013-08-05 20:52:22 +1000
commit26ae657950272439be23e02057debf5d83265436 (patch)
treeac1858e6cb503ade12c0ea39b22dc2c64537603e /pwdx.c
parentb83788993bb2aeb2a6074ac8a2a08d4b9e49102b (diff)
downloadprocps-ng-26ae657950272439be23e02057debf5d83265436.tar.gz
pwdx: fails when run in a nonexistent locale
pwdx rather mysteriously fails with "invalid process id" when run in a nonexistent locale (e.g. "LC_ALL=foo pwdx $$"). This is because it fails to obey the documented calling sequence for strtol - that is, set errno to 0 before the call - and thus the errno from the setlocale failure bleeds over into its check for whether strtol failed. References: http://bugs.debian.org/718766 Signed-off-by: Craig Small <csmall@enc.com.au>
Diffstat (limited to 'pwdx.c')
-rw-r--r--pwdx.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/pwdx.c b/pwdx.c
index 214275a..9d40902 100644
--- a/pwdx.c
+++ b/pwdx.c
@@ -52,6 +52,7 @@ int check_pid_argument(char *input)
if (!strncmp("/proc/", input, 6))
skip = 6;
+ errno = 0;
pid = strtol(input + skip, &end, 10);
if (errno || input + skip == end || (end && *end))