Module: kamailio
Branch: master
Commit: 702630b484ac6f7c017829c24294ce7552f1682a
URL: 
https://github.com/kamailio/kamailio/commit/702630b484ac6f7c017829c24294ce7552f1682a

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2020-05-12T18:01:15+02:00

imc: reserve last char in global buffer for ending zero

---

Modified: src/modules/imc/imc_cmd.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/702630b484ac6f7c017829c24294ce7552f1682a.diff
Patch: 
https://github.com/kamailio/kamailio/commit/702630b484ac6f7c017829c24294ce7552f1682a.patch

---

diff --git a/src/modules/imc/imc_cmd.c b/src/modules/imc/imc_cmd.c
index 757b17b342..bf68967d21 100644
--- a/src/modules/imc/imc_cmd.c
+++ b/src/modules/imc/imc_cmd.c
@@ -960,7 +960,8 @@ int imc_handle_members(struct sip_msg* msg, imc_cmd_t *cmd,
        }
 
        p = imc_body_buf;
-       left = sizeof(imc_body_buf);
+       imc_body_buf[IMC_BUF_SIZE - 1] = '\0';
+       left = sizeof(imc_body_buf) - 1;
 
        memcpy(p, MEMBERS, sizeof(MEMBERS) - 1);
        p += sizeof(MEMBERS) - 1;
@@ -975,22 +976,22 @@ int imc_handle_members(struct sip_msg* msg, imc_cmd_t 
*cmd,
                }
 
                if (imp->flags & IMC_MEMBER_OWNER) {
-                       if (left < 1) goto overrun;
+                       if (left < 2) goto overrun;
                        *p++ = '*';
                        left--;
                } else if (imp->flags & IMC_MEMBER_ADMIN) {
-                       if (left < 1) goto overrun;
+                       if (left < 2) goto overrun;
                        *p++ = '~';
                        left--;
                }
 
                name = format_uri(imp->uri);
-               if (left < name->len) goto overrun;
+               if (left < name->len + 1) goto overrun;
                strncpy(p, name->s, name->len);
                p += name->len;
                left -= name->len;
 
-               if (left < 1) goto overrun;
+               if (left < 2) goto overrun;
                *p++ = '\n';
                left--;
 


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to