diff options
author | Ben Pfaff <blp@nicira.com> | 2011-08-18 10:33:32 -0700 |
---|---|---|
committer | Ben Pfaff <blp@nicira.com> | 2011-08-18 11:37:44 -0700 |
commit | fac2e5163cb349ec33d8d2bdda2e73f35e50d4d5 (patch) | |
tree | 60485c3708108d21eb0fb76961b7943f9b0b8255 /lib/odp-util.c | |
parent | 338fb44ad67e59f09664f502f2c4325cff1e5080 (diff) |
odp-util: Fix parsing of Ethertypes 0x8000 and above.
An existing comment in the function being updated explains the problem:
* Many of the sscanf calls in this function use oversized destination
* fields because some sscanf() implementations truncate the range of %i
* directives, so that e.g. "%"SCNi16 interprets input of "0xfedc" as a
* value of 0x7fff. The other alternatives are to allow only a single
* radix (e.g. decimal or hexadecimal) or to write more sophisticated
* parsers.
Diffstat (limited to 'lib/odp-util.c')
-rw-r--r-- | lib/odp-util.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/odp-util.c b/lib/odp-util.c index b4163805..00e4627b 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -480,10 +480,10 @@ parse_odp_key_attr(const char *s, struct ofpbuf *key) } { - uint16_t eth_type; + int eth_type; int n = -1; - if (sscanf(s, "eth_type(%"SCNi16")%n", ð_type, &n) > 0 && n > 0) { + if (sscanf(s, "eth_type(%i)%n", ð_type, &n) > 0 && n > 0) { nl_msg_put_be16(key, ODP_KEY_ATTR_ETHERTYPE, htons(eth_type)); return n; } |