Module: kamailio
Branch: master
Commit: 413c90202975886f4dfcb579a1157a19c3065341
URL: 
https://github.com/kamailio/kamailio/commit/413c90202975886f4dfcb579a1157a19c3065341

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-02-16T10:36:57+01:00

core: socket info - print index values in error message for overflow

---

Modified: src/core/socket_info.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/413c90202975886f4dfcb579a1157a19c3065341.diff
Patch: 
https://github.com/kamailio/kamailio/commit/413c90202975886f4dfcb579a1157a19c3065341.patch

---

diff --git a/src/core/socket_info.c b/src/core/socket_info.c
index 4fd44fec2dc..dac3f08a6e6 100644
--- a/src/core/socket_info.c
+++ b/src/core/socket_info.c
@@ -1453,22 +1453,22 @@ static int get_flags(int family)
        }
 
        while(1) {
-               if(sizeof(buf) <= nll) {
-                       LM_ERR("netlink buffer overflow in get_flags");
-                       goto error;
-               }
                rtn = recv(nl_sock, p, sizeof(buf) - nll, 0);
                if(rtn <= 0) {
                        LM_ERR("failed to receive data (%d/%d)\n", rtn, errno);
                        goto error;
                }
+               if(nll >= sizeof(buf) - rtn) {
+                       LM_ERR("netlink buffer overflow [%u/%d]\n", nll, rtn);
+                       goto error;
+               }
                nlp = (struct nlmsghdr *)p;
                if(nlp->nlmsg_type == NLMSG_DONE) {
                        LM_DBG("done\n");
                        break;
                }
                if(nlp->nlmsg_type == NLMSG_ERROR) {
-                       LM_DBG("Error on message to netlink");
+                       LM_DBG("error on message to netlink");
                        break;
                }
                p += rtn;

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to