dev.dpdk.org archive mirror
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] rte_ether: force format string for unformat_addr
@ 2019-07-10 18:33 Aaron Conole
  2019-07-10 18:42 ` Stephen Hemminger
  0 siblings, 1 reply; 9+ messages in thread
From: Aaron Conole @ 2019-07-10 18:33 UTC (permalink / raw)
  To: dev; +Cc: Olivier Matz, Stephen Hemminger, Andrew Rybchenko, Ferruh Yigit

rte_ether_unformation_addr is very lax in what it accepts now, including
ethernet addresses formatted ambiguously as "x:xx:x:xx:x:xx".  However,
previously this behavior was enforced via the my_ether_aton which would
fail ambiguously formatted values.

Reported-by: Michael Santana <msantana@redhat.com>
Fixes: 596d31092d32 ("net: add function to convert string to ethernet address")
Signed-off-by: Aaron Conole <aconole@redhat.com>
---
 lib/librte_net/rte_ether.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/librte_net/rte_ether.c b/lib/librte_net/rte_ether.c
index 8d040173c..4f252b813 100644
--- a/lib/librte_net/rte_ether.c
+++ b/lib/librte_net/rte_ether.c
@@ -45,7 +45,8 @@ rte_ether_unformat_addr(const char *s, struct rte_ether_addr *ea)
 	if (n == 6) {
 		/* Standard format XX:XX:XX:XX:XX:XX */
 		if (o0 > UINT8_MAX || o1 > UINT8_MAX || o2 > UINT8_MAX ||
-		    o3 > UINT8_MAX || o4 > UINT8_MAX || o5 > UINT8_MAX) {
+		    o3 > UINT8_MAX || o4 > UINT8_MAX || o5 > UINT8_MAX ||
+		    strlen(s) != RTE_ETHER_ADDR_FMT_SIZE - 1) {
 			rte_errno = ERANGE;
 			return -1;
 		}
@@ -58,7 +59,8 @@ rte_ether_unformat_addr(const char *s, struct rte_ether_addr *ea)
 		ea->addr_bytes[5] = o5;
 	} else if (n == 3) {
 		/* Support the format XXXX:XXXX:XXXX */
-		if (o0 > UINT16_MAX || o1 > UINT16_MAX || o2 > UINT16_MAX) {
+		if (o0 > UINT16_MAX || o1 > UINT16_MAX || o2 > UINT16_MAX ||
+		    strlen(s) != RTE_ETHER_ADDR_FMT_SIZE - 4) {
 			rte_errno = ERANGE;
 			return -1;
 		}
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-07-21 17:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-10 18:33 [dpdk-dev] [PATCH] rte_ether: force format string for unformat_addr Aaron Conole
2019-07-10 18:42 ` Stephen Hemminger
2019-07-10 19:13   ` Aaron Conole
2019-07-10 19:27     ` Stephen Hemminger
2019-07-10 20:31       ` Aaron Conole
2019-07-10 23:13         ` Stephen Hemminger
2019-07-17 18:42         ` Stephen Hemminger
2019-07-19 17:59           ` Ferruh Yigit
2019-07-21 17:32             ` Aaron Conole

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).