daemon_vty: avoid null-dereference in argc < 0 case

in show_gtp_cmd, we have two different checks (argc > 0) vs (argc)
which means in theory argc could be negative and the second clause
would be executed without the first having set up related data such as
'ai'.

Fixes: CID#307521: Explicit null dereferenced (FORWARD_NULL)
Change-Id: I4149b0b191a34168ba6649338d3cdf6c6af6cfe7
This commit is contained in:
Harald Welte 2023-07-18 14:35:41 +02:00
parent 3f2361ee33
commit e36dbcbc03
1 changed files with 1 additions and 1 deletions

View File

@ -145,7 +145,7 @@ DEFUN(show_gtp, show_gtp_cmd,
show_ep_hdr(vty);
pthread_rwlock_rdlock(&g_daemon->rwlock);
if (argc) {
if (argc > 0) {
ep = _gtp_endpoint_find(g_daemon, (const struct sockaddr_storage *) ai->ai_addr);
if (!ep) {
pthread_rwlock_unlock(&g_daemon->rwlock);