From c10c9cd5e619f61368c0f21a13c3bb1ae48ec1b8 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sun, 13 Jul 2014 07:08:12 -0600 Subject: [PATCH] Skip leading space (ala strtol) so that we can pick up the sign even if it is not the first character of the string. --- lib/util/strtoid.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/util/strtoid.c b/lib/util/strtoid.c index 9d1c9fbc8..623ea685a 100644 --- a/lib/util/strtoid.c +++ b/lib/util/strtoid.c @@ -37,6 +37,7 @@ #else # include "compat/stdbool.h" #endif +#include #include #include @@ -62,6 +63,9 @@ sudo_strtoid(const char *p, const char *sep, char **endp, const char **errstr) bool valid = false; debug_decl(sudo_strtoid, SUDO_DEBUG_UTIL) + /* skip leading space so we can pick up the sign, if any */ + while (isspace((unsigned char)*p)) + p++; if (sep == NULL) sep = ""; errno = 0;