app/test-fib: fix unchecked return value

Message ID e12f63c5bd8af410eb0c3d2c2455e1d89d6ad51b.1589188908.git.vladimir.medvedkin@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series app/test-fib: fix unchecked return value |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/travis-robot success Travis build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-nxp-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-testing fail Testing issues

Commit Message

Vladimir Medvedkin May 11, 2020, 9:22 a.m. UTC
  Check returned value after strtok()
CID 355674 (#1 of 1): Dereference null return value (NULL_RETURNS)
4. dereference: Dereferencing a pointer that might be NULL s when
calling inet_pton

Fixes: 103809d032cd ("app/test-fib: add test application for FIB")
Cc: stable@dpdk.org

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
---
 app/test-fib/main.c | 2 ++
 1 file changed, 2 insertions(+)
  

Comments

Thomas Monjalon May 19, 2020, 5:45 p.m. UTC | #1
11/05/2020 11:22, Vladimir Medvedkin:
> Check returned value after strtok()
> CID 355674 (#1 of 1): Dereference null return value (NULL_RETURNS)
> 4. dereference: Dereferencing a pointer that might be NULL s when
> calling inet_pton
> 
> Fixes: 103809d032cd ("app/test-fib: add test application for FIB")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>

Applied, thanks
  

Patch

diff --git a/app/test-fib/main.c b/app/test-fib/main.c
index 6e80d65..9cf01b1 100644
--- a/app/test-fib/main.c
+++ b/app/test-fib/main.c
@@ -543,6 +543,8 @@  parse_lookup(FILE *f, int af)
 
 	while (fgets(line, sizeof(line), f) != NULL) {
 		s = strtok(line, " \t\n");
+		if (s == NULL)
+			return -EINVAL;
 		ret = inet_pton(af, s, &tbl[i]);
 		if (ret != 1)
 			return -EINVAL;