git.droids-corp.org
/
dpdk.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
cmdline: fix overflow on bsd
[dpdk.git]
/
lib
/
librte_cmdline
/
cmdline_parse_etheraddr.c
diff --git
a/lib/librte_cmdline/cmdline_parse_etheraddr.c
b/lib/librte_cmdline/cmdline_parse_etheraddr.c
index
5e11631
..
64ae86c
100644
(file)
--- a/
lib/librte_cmdline/cmdline_parse_etheraddr.c
+++ b/
lib/librte_cmdline/cmdline_parse_etheraddr.c
@@
-137,12
+137,15
@@
my_ether_aton(const char *a)
int
cmdline_parse_etheraddr(__attribute__((unused)) cmdline_parse_token_hdr_t *tk,
int
cmdline_parse_etheraddr(__attribute__((unused)) cmdline_parse_token_hdr_t *tk,
-
const char *buf, void *res
)
+
const char *buf, void *res, unsigned ressize
)
{
unsigned int token_len = 0;
char ether_str[ETHER_ADDRSTRLENLONG+1];
struct ether_addr *tmp;
{
unsigned int token_len = 0;
char ether_str[ETHER_ADDRSTRLENLONG+1];
struct ether_addr *tmp;
+ if (res && ressize < sizeof(struct ether_addr))
+ return -1;
+
if (!buf || ! *buf)
return -1;
if (!buf || ! *buf)
return -1;
@@
-154,7
+157,7
@@
cmdline_parse_etheraddr(__attribute__((unused)) cmdline_parse_token_hdr_t *tk,
(token_len != ETHER_ADDRSTRLENSHORT - 1))
return -1;
(token_len != ETHER_ADDRSTRLENSHORT - 1))
return -1;
-
rte_
snprintf(ether_str, token_len+1, "%s", buf);
+ snprintf(ether_str, token_len+1, "%s", buf);
tmp = my_ether_aton(ether_str);
if (tmp == NULL)
tmp = my_ether_aton(ether_str);
if (tmp == NULL)
@@
-170,7
+173,7
@@
cmdline_get_help_etheraddr(__attribute__((unused)) cmdline_parse_token_hdr_t *tk
{
int ret;
{
int ret;
- ret =
rte_
snprintf(dstbuf, size, "Ethernet address");
+ ret = snprintf(dstbuf, size, "Ethernet address");
if (ret < 0)
return -1;
return 0;
if (ret < 0)
return -1;
return 0;