strtol already ignores leading whitespace so it doesn't make much sense
for us to worry about trailing whitespace.

Signed-off-by: Andrew Gregory <[email protected]>
---
 src/pacman/util.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index 7b7dace..115f328 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1292,6 +1292,10 @@ static int parseindex(char *s, int *val, int min, int 
max)
 {
        char *endptr = NULL;
        int n = strtol(s, &endptr, 10);
+       /* strtol skips leading whitespace, don't worry about trailing 
whitespace */
+       while(isspace(*endptr)) {
+                       endptr++;
+       }
        if(*endptr == '\0') {
                if(n < min || n > max) {
                        pm_printf(ALPM_LOG_ERROR,
-- 
1.8.2


Reply via email to