[sr-dev] git:master:ef31c82a: core: cfg.len - sanitizer safety check of target buffer

Daniel-Constantin Mierla miconda at gmail.com
Mon Apr 5 17:35:56 CEST 2021


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-04-05T17:31:48+02:00

core: cfg.len - sanitizer safety check of target buffer

---

Modified: src/core/cfg.lex

---

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

---

diff --git a/src/core/cfg.lex b/src/core/cfg.lex
index afab5b68a5..b8e4f9aa70 100644
--- a/src/core/cfg.lex
+++ b/src/core/cfg.lex
@@ -1593,7 +1593,7 @@ static char* addchar(struct str_buf* dst, char c)
 
 static char* addstr(struct str_buf* dst_b, char* src, int len)
 {
-	char *tmp;
+	char *tmp = NULL;
 	unsigned size;
 	unsigned used;
 
@@ -1612,6 +1612,10 @@ static char* addstr(struct str_buf* dst_b, char* src, int len)
 		dst_b->crt=dst_b->s+used;
 		dst_b->left=size-used;
 	}
+	if(dst_b->crt==NULL) {
+		LM_CRIT("unexpected null dst buffer\n");
+		ksr_exit(-1);
+	}
 	memcpy(dst_b->crt, src, len);
 	dst_b->crt+=len;
 	*(dst_b->crt)=0;




More information about the sr-dev mailing list