If an integer is surrounded by whitespace, it's still an integer
authorAlan T. DeKok <aland@freeradius.org>
Mon, 24 May 2010 05:35:31 +0000 (07:35 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 24 May 2010 05:39:16 +0000 (07:39 +0200)
src/lib/valuepair.c

index 6ea206b..8cdf673 100644 (file)
@@ -830,6 +830,18 @@ static uint32_t getint(const char *value, char **end)
        return strtoul(value, end, 10);
 }
 
+static int check_for_whitespace(const char *value)
+{
+       while (*value) {
+               if (!isspace((int) *value)) return 0;
+
+               value++;
+       }
+
+       return 1;
+}
+
+
 VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value)
 {
        char            *p, *s=0;
@@ -963,6 +975,7 @@ VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value)
                                }
                                break;
                        }
+                       if (check_for_whitespace(p)) break;
                        goto check_for_value;
 
                case PW_TYPE_SHORT:
@@ -978,7 +991,7 @@ VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value)
                                }
                                break;
                        }
-
+                       if (check_for_whitespace(p)) break;
                        goto check_for_value;
 
                case PW_TYPE_INTEGER:
@@ -988,6 +1001,7 @@ VALUE_PAIR *pairparsevalue(VALUE_PAIR *vp, const char *value)
                        vp->vp_integer = getint(value, &p);
                        vp->length = 4;
                        if (!*p) break;
+                       if (check_for_whitespace(p)) break;
 
        check_for_value:
                        /*