diff mbox

example: l3fwd: check rc from odph_eth_addr_parse()

Message ID 20170405211620.10245-1-bill.fischofer@linaro.org
State Superseded
Headers show

Commit Message

Bill Fischofer April 5, 2017, 9:16 p.m. UTC
Resolve Bug https://bugs.linaro.org/show_bug.cgi?id=2779 by checking
the return code from odph_eth_addr_parse() and failing the call if
dst_mac is unparseable.

Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

---
 example/l3fwd/odp_l3fwd_db.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.9.3

Comments

Maxim Uvarov April 12, 2017, 7:10 p.m. UTC | #1
On 04/06/17 00:16, Bill Fischofer wrote:
> Resolve Bug https://bugs.linaro.org/show_bug.cgi?id=2779 by checking

> the return code from odph_eth_addr_parse() and failing the call if

> dst_mac is unparseable.

> 

> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

> ---

>  example/l3fwd/odp_l3fwd_db.c | 3 ++-

>  1 file changed, 2 insertions(+), 1 deletion(-)

> 

> diff --git a/example/l3fwd/odp_l3fwd_db.c b/example/l3fwd/odp_l3fwd_db.c

> index 082b2c2..7d1efd5 100644

> --- a/example/l3fwd/odp_l3fwd_db.c

> +++ b/example/l3fwd/odp_l3fwd_db.c

> @@ -394,7 +394,8 @@ int create_fwd_db_entry(char *input, char **oif, uint8_t **dst_mac)

>  			*oif = entry->oif;

>  			break;

>  		case 2:

> -			odph_eth_addr_parse(&entry->dst_mac, token);

> +			if (odph_eth_addr_parse(&entry->dst_mac, token) < 0)

> +				return -1;


free(local) is missing

Maxim.

>  			*dst_mac = entry->dst_mac.addr;

>  			break;

>  

>
Bill Fischofer April 12, 2017, 7:41 p.m. UTC | #2
On Wed, Apr 12, 2017 at 2:10 PM, Maxim Uvarov <maxim.uvarov@linaro.org> wrote:
> On 04/06/17 00:16, Bill Fischofer wrote:

>> Resolve Bug https://bugs.linaro.org/show_bug.cgi?id=2779 by checking

>> the return code from odph_eth_addr_parse() and failing the call if

>> dst_mac is unparseable.

>>

>> Signed-off-by: Bill Fischofer <bill.fischofer@linaro.org>

>> ---

>>  example/l3fwd/odp_l3fwd_db.c | 3 ++-

>>  1 file changed, 2 insertions(+), 1 deletion(-)

>>

>> diff --git a/example/l3fwd/odp_l3fwd_db.c b/example/l3fwd/odp_l3fwd_db.c

>> index 082b2c2..7d1efd5 100644

>> --- a/example/l3fwd/odp_l3fwd_db.c

>> +++ b/example/l3fwd/odp_l3fwd_db.c

>> @@ -394,7 +394,8 @@ int create_fwd_db_entry(char *input, char **oif, uint8_t **dst_mac)

>>                       *oif = entry->oif;

>>                       break;

>>               case 2:

>> -                     odph_eth_addr_parse(&entry->dst_mac, token);

>> +                     if (odph_eth_addr_parse(&entry->dst_mac, token) < 0)

>> +                             return -1;

>

> free(local) is missing


Thanks! v2 sent.

>

> Maxim.

>

>>                       *dst_mac = entry->dst_mac.addr;

>>                       break;

>>

>>

>
diff mbox

Patch

diff --git a/example/l3fwd/odp_l3fwd_db.c b/example/l3fwd/odp_l3fwd_db.c
index 082b2c2..7d1efd5 100644
--- a/example/l3fwd/odp_l3fwd_db.c
+++ b/example/l3fwd/odp_l3fwd_db.c
@@ -394,7 +394,8 @@  int create_fwd_db_entry(char *input, char **oif, uint8_t **dst_mac)
 			*oif = entry->oif;
 			break;
 		case 2:
-			odph_eth_addr_parse(&entry->dst_mac, token);
+			if (odph_eth_addr_parse(&entry->dst_mac, token) < 0)
+				return -1;
 			*dst_mac = entry->dst_mac.addr;
 			break;