]> granicus.if.org Git - sudo/commitdiff
Skip leading space (ala strtol) so that we can pick up the sign
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 13 Jul 2014 13:08:12 +0000 (07:08 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sun, 13 Jul 2014 13:08:12 +0000 (07:08 -0600)
even if it is not the first character of the string.

lib/util/strtoid.c

index 9d1c9fbc85f4183a1a759d58cfa44067a96c5da2..623ea685ad3a78851b072c50b9818c7874a790ab 100644 (file)
@@ -37,6 +37,7 @@
 #else
 # include "compat/stdbool.h"
 #endif
+#include <ctype.h>
 #include <errno.h>
 #include <limits.h>
 
@@ -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;