[sr-dev] git:master:5e42adae: core: initialize memory to 0 in cfg parser in a few more places

Henning Westerholt hw at skalatan.de
Thu Mar 5 17:32:15 CET 2020


Module: kamailio
Branch: master
Commit: 5e42adae624f9741e26dfb0af4accede2a8f92d2
URL: https://github.com/kamailio/kamailio/commit/5e42adae624f9741e26dfb0af4accede2a8f92d2

Author: Henning Westerholt <hw at skalatan.de>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2020-03-05T17:31:53+01:00

core: initialize memory to 0 in cfg parser in a few more places

---

Modified: src/core/cfg.y

---

Diff:  https://github.com/kamailio/kamailio/commit/5e42adae624f9741e26dfb0af4accede2a8f92d2.diff
Patch: https://github.com/kamailio/kamailio/commit/5e42adae624f9741e26dfb0af4accede2a8f92d2.patch

---

diff --git a/src/core/cfg.y b/src/core/cfg.y
index 6319f8b5b4..29b5b4aa1d 100644
--- a/src/core/cfg.y
+++ b/src/core/cfg.y
@@ -2673,7 +2673,7 @@ attr_mark:
 	ATTR_MARK {
 		s_attr = (struct avp_spec*)pkg_malloc(sizeof(struct avp_spec));
 		if (!s_attr) { yyerror("No memory left"); YYABORT; }
-		else s_attr->type = 0;
+		else { memset(s_attr, 0, (sizeof(struct avp_spec))); s_attr->type = 0; }
 	}
 	;
 attr_id:
@@ -3712,6 +3712,7 @@ static struct name_lst* mk_name_lst(char* host, int flags)
 	if (l==0) {
 		PKG_MEM_CRITICAL;
 	} else {
+		memset(l, 0, sizeof(struct name_lst));
 		l->name=host;
 		l->flags=flags;
 		l->next=0;
@@ -3728,6 +3729,7 @@ static struct socket_id* mk_listen_id(char* host, int proto, int port)
 	if (l==0) {
 		PKG_MEM_CRITICAL;
 	} else {
+		memset(l, 0, sizeof(struct socket_id));
 		l->addr_lst=mk_name_lst(host, 0);
 		if (l->addr_lst==0){
 			pkg_free(l);
@@ -3763,6 +3765,7 @@ static struct socket_id* mk_listen_id2(struct name_lst* addr_l, int proto,
 	if (l==0) {
 		PKG_MEM_CRITICAL;
 	} else {
+		memset(l, 0, sizeof(struct socket_id));
 		l->flags=addr_l->flags;
 		l->port=port;
 		l->proto=proto;




More information about the sr-dev mailing list