laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/37894?usp=email )
Change subject: src/core/socket.c: Fix close of negative fd in system_supports_inet6() ......................................................................
src/core/socket.c: Fix close of negative fd in system_supports_inet6()
*** CID 413596: Error handling issues (NEGATIVE_RETURNS) /source-Osmocom/libosmocore/src/core/socket.c: 293 in system_supports_inet6() 287 if (cached_val < 0) { 288 int rc = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); 289 if (rc < 0 && errno == EAFNOSUPPORT) { 290 cached_val = 0; 291 } else { 292 cached_val = 1;
CID 413596: Error handling issues (NEGATIVE_RETURNS) "rc" is passed to a parameter that cannot be negative.
293 close(rc); 294 } 295 } 296 return cached_val == 1; 297 } 298
Change-Id: Iedd0f74688cacd8dbe4b46b2c7e03a6c2f56fbbf Fixes: Change-Id I5690a25af98089e3a8a092cb91dfc969720abdc0 Closes: CID#413596 --- M src/core/socket.c 1 file changed, 1 insertion(+), 1 deletion(-)
Approvals: lynxis lazus: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified
diff --git a/src/core/socket.c b/src/core/socket.c index da20981..90cf4ca 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -288,7 +288,7 @@ int rc = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP); if (rc < 0 && errno == EAFNOSUPPORT) { cached_val = 0; - } else { + } else if (rc >= 0) { cached_val = 1; close(rc); }