From 26ae657950272439be23e02057debf5d83265436 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 5 Aug 2013 20:52:22 +1000 Subject: [PATCH] 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 --- pwdx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pwdx.c b/pwdx.c index 214275a9..9d409027 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))