[ovs-dev] [PATCH] lib/ofp-util: Restore the check for minus sign in port number strings.

Jarno Rajahalme jrajahalme at nicira.com
Fri Apr 18 01:36:41 UTC 2014


Commit 33ab38d9 (meta-flow: Simplify mf_from_ofp_port_string())
inadvertently removed a check for minus sign at the beginning of a
port number string introduced by commit 05dddba (meta-flow: Don't
allow negative port numbers).  This check is still needed, so put it
back, but to ofputil_port_from_string() this time.

Signed-off-by: Jarno Rajahalme <jrajahalme at nicira.com>
---
 lib/ofp-util.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/ofp-util.c b/lib/ofp-util.c
index af2d853..a990f46 100644
--- a/lib/ofp-util.c
+++ b/lib/ofp-util.c
@@ -5394,8 +5394,12 @@ ofputil_port_to_ofp11(ofp_port_t ofp10_port)
 bool
 ofputil_port_from_string(const char *s, ofp_port_t *portp)
 {
-    uint32_t port32;
+    unsigned int port32; /* int is at least 32 bits wide. */
 
+    if (*s == '-') {
+        VLOG_WARN("Negative values are not supported as port numbers.");
+        return false;
+    }
     *portp = 0;
     if (str_to_uint(s, 10, &port32)) {
         if (port32 < ofp_to_u16(OFPP_MAX)) {
-- 
1.7.10.4




More information about the dev mailing list