From: Jarno Rajahalme Date: Fri, 18 Apr 2014 15:26:56 +0000 (-0700) Subject: lib/ofp-util: Restore the check for minus sign in port number strings. X-Git-Tag: sliver-openvswitch-2.2.90-1~3^2~120 X-Git-Url: http://git.onelab.eu/?p=sliver-openvswitch.git;a=commitdiff_plain;h=5b23ff7e7da56ee6fad43fe967f1b2a5beeb4893 lib/ofp-util: Restore the check for minus sign in port number strings. 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 Acked-by: Justin Pettit Reviewed-by: YAMAMOTO Takashi --- diff --git a/lib/ofp-util.c b/lib/ofp-util.c index af2d853eb..6367e6f6d 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 value %s is not a valid port number.", s); + return false; + } *portp = 0; if (str_to_uint(s, 10, &port32)) { if (port32 < ofp_to_u16(OFPP_MAX)) {