[sr-dev] git:master:136071c4: core: re - check source of memcpy

Daniel-Constantin Mierla miconda at gmail.com
Fri Nov 19 08:38:18 CET 2021


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-11-19T08:25:45+01:00

core: re - check source of memcpy

---

Modified: src/core/re.c

---

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

---

diff --git a/src/core/re.c b/src/core/re.c
index 4ce18d8c4d..47322284b6 100644
--- a/src/core/re.c
+++ b/src/core/re.c
@@ -339,8 +339,10 @@ static int replace_build(const char* match, int nmatch, regmatch_t* pmatch,
 		LM_ERR("Buffer too small\n");			\
 		goto error;											\
 	}														\
-	memcpy((dst), (src), (size));							\
-	(dst) += (size);
+	if(likely(src)) {							\
+		memcpy((dst), (src), (size));			\
+		(dst) += (size);						\
+	}
 
 	p=se->replacement.s;
 	end=p+se->replacement.len;




More information about the sr-dev mailing list