[ovs-dev] [PATCH] util: Make parse_int_string() only succeed if it parses a non-empty string.

Ben Pfaff blp at ovn.org
Wed Dec 19 03:13:56 UTC 2018


strtoull() doesn't necessarily set errno if it finds nothing to parse, but
this code didn't check for that case.

Reported-by: Ilya Maximets <i.maximets at samsung.com>
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2018-December/354622.html
Signed-off-by: Ben Pfaff <blp at ovn.org>
---
 lib/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/util.c b/lib/util.c
index 66544bff38ea..fcd4e753613e 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -968,7 +968,7 @@ free:
 
     errno = 0;
     integer = strtoull(s, tail, 0);
-    if (errno) {
+    if (errno || s == *tail) {
         return errno;
     }
 
-- 
2.16.1



More information about the dev mailing list