[sr-dev] git:5.0:99f3b4c6: erlang: fix copy into fixed size buffer of node name

Seudin Kasumovic seudin.kasumovic at gmail.com
Thu Jan 4 09:30:52 CET 2018


Module: kamailio
Branch: 5.0
Commit: 99f3b4c687b12eeff4f45359404886dd1ce29537
URL: https://github.com/kamailio/kamailio/commit/99f3b4c687b12eeff4f45359404886dd1ce29537

Author: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Committer: Seudin Kasumovic <seudin.kasumovic at gmail.com>
Date: 2018-01-04T09:26:19+01:00

erlang: fix copy into fixed size buffer of node name

Use length of node name string to avoid write past the end of the
fixed-size destination buffer.

(cherry picked from commit 53a76a4ae828cf08fbdebe08918706bd7d7d76d2)

---

Modified: src/modules/erlang/cnode.c

---

Diff:  https://github.com/kamailio/kamailio/commit/99f3b4c687b12eeff4f45359404886dd1ce29537.diff
Patch: https://github.com/kamailio/kamailio/commit/99f3b4c687b12eeff4f45359404886dd1ce29537.patch

---

diff --git a/src/modules/erlang/cnode.c b/src/modules/erlang/cnode.c
index 0eae7a716c..ce24c1dff4 100644
--- a/src/modules/erlang/cnode.c
+++ b/src/modules/erlang/cnode.c
@@ -111,7 +111,8 @@ int cnode_connect_to(cnode_handler_t *phandler, ei_cnode *ec, const str *nodenam
 		LM_DBG("... connected to %.*s %s:%u\n", STR_FMT(nodename), ip_addr2strz(&ip), port);
 	}
 
-	strcpy(phandler->conn.nodename, nodename->s);
+	strncpy(phandler->conn.nodename, nodename->s, nodename->len);
+	phandler->conn.nodename[nodename->len] = 0;
 
 	/* for #Pid */
 	phandler->ec.self.num = phandler->sockfd;




More information about the sr-dev mailing list