Skip leading space (ala strtol) so that we can pick up the sign

even if it is not the first character of the string.
This commit is contained in:
Todd C. Miller
2014-07-13 07:08:12 -06:00
parent cedc34561d
commit c10c9cd5e6

View 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;