[S] Change in libosmocore[master]: socket: Ensure fd is not negative in osmo_sock_get_name_buf()
daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/33333 ) Change subject: socket: Ensure fd is not negative in osmo_sock_get_name_buf() ...................................................................... socket: Ensure fd is not negative in osmo_sock_get_name_buf() Write to str even in case of error because this is already the current behaviour and it's what osmo_stream_cli_get_sockname() and osmo_sock_get_name2{,_c}() expect. Change-Id: I76727993224ef87b475c33360c24966e82e866ec Fixes: Coverity CID#321044 --- M src/core/socket.c 1 file changed, 19 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/33/33333/1 diff --git a/src/core/socket.c b/src/core/socket.c index 1b14794..02e16bc 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -1550,6 +1550,11 @@ char portbuf_l[6], portbuf_r[6]; int rc; + if (fd < 0) { + osmo_strlcpy(str, "<error-bad-fd>", str_len); + return -EBADF; + } + /* get local */ if ((rc = osmo_sock_get_ip_and_port(fd, hostbuf_l, sizeof(hostbuf_l), portbuf_l, sizeof(portbuf_l), true))) { osmo_strlcpy(str, "<error-in-getsockname>", str_len); -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/33333 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I76727993224ef87b475c33360c24966e82e866ec Gerrit-Change-Number: 33333 Gerrit-PatchSet: 1 Gerrit-Owner: daniel <dwillmann@sysmocom.de> Gerrit-MessageType: newchange
participants (1)
-
daniel