lib/util: Input validation in str_to_uint
authorZoltan Kiss <zoltan.kiss@citrix.com>
Wed, 23 Apr 2014 13:45:21 +0000 (14:45 +0100)
committerBen Pfaff <blp@nicira.com>
Wed, 23 Apr 2014 18:46:55 +0000 (11:46 -0700)
commit4c21aa063fa1c7f95800c95fafebedcd577ce674
tree9d2110871b26173f5cf31e7cc2aa9ee3f25932df
parent34799871bf18ce7d6124e137dcca31ef88af9156
lib/util: Input validation in str_to_uint

This function returns true when 's' is negative or greater than UINT_MAX. Also,
the representation of 'int' and 'unsigned int' is implementation dependent, so
converting [INT_MAX..UINT_MAX] values with str_to_int is fragile.
Instead, we should convert straight to 'long long' and do a boundary check
before returning the converted value.
This patch also move the function to the .c file as it's not-trivial now, and
deletes the other str_to_u* functions as they are not used.

Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/util.c
lib/util.h