[ovs-dev] [PATCH] lib: ofp-parse segfaults if required argument isn't specified

Ethan Jackson ethan at nicira.com
Fri Oct 8 22:17:44 UTC 2010


Running ovs-ofctl add-flow br0 "in_port=3 actions=resubmit" would
segfault instead of reporting an error.
---
 lib/ofp-parse.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/ofp-parse.c b/lib/ofp-parse.c
index 7a88880..128685e 100644
--- a/lib/ofp-parse.c
+++ b/lib/ofp-parse.c
@@ -40,6 +40,10 @@ str_to_u32(const char *str)
     char *tail;
     uint32_t value;
 
+    if (!str) {
+        ovs_fatal(0, "invalid numeric format <NULL>");
+    }
+
     errno = 0;
     value = strtoul(str, &tail, 0);
     if (errno == EINVAL || errno == ERANGE || *tail) {
-- 
1.7.3.1





More information about the dev mailing list