summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2019-02-15 04:43:33 +0100
committerGuillem Jover <guillem@debian.org>2019-02-23 15:20:11 +0100
commit090c1a51040557c0361776ed7bf297722dbfd4b3 (patch)
tree6da144456e8361531ff8629e1d9369e9fdf387b6
parentdb3872abfb48ff4a5393f3c2fe343a63d90395f6 (diff)
downloaddpkg-090c1a51040557c0361776ed7bf297722dbfd4b3.tar.gz
s-s-d: Make sure that we get a meaningful errno on parse_unsigned()
Initialize errno to 0 before returning on any error condition, not just before strtol(3), so that when we call fatal() we get a meaningful value in errno.
-rw-r--r--debian/changelog2
-rw-r--r--utils/start-stop-daemon.c2
2 files changed, 3 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index 6d95110ae..e2f7bd67d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
dpkg (1.19.5) UNRELEASED; urgency=medium
[ Guillem Jover ]
+ * start-stop-daemon: Make sure that we get a meaningful errno on
+ parse_unsigned(), so that the error messages always make sense.
* Build system:
- Check whether this dist is a release, based only on the version format.
This will avoid having to do a two staged release to get a proper perl
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index 7a52643f8..035ee0306 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -448,10 +448,10 @@ parse_unsigned(const char *string, int base, int *value_r)
long value;
char *endptr;
+ errno = 0;
if (!string[0])
return -1;
- errno = 0;
value = strtol(string, &endptr, base);
if (string == endptr || *endptr != '\0' || errno != 0)
return -1;