[sr-dev] git:4.2:d08a9258: exec: proper handling of empty headers for exec_bash_safety

Daniel-Constantin Mierla miconda at gmail.com
Tue Jan 13 12:41:28 CET 2015


Module: kamailio
Branch: 4.2
Commit: d08a925872aa9bb2b22552171281cbe18783cbef
URL: https://github.com/kamailio/kamailio/commit/d08a925872aa9bb2b22552171281cbe18783cbef

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2015-01-13T12:41:05+01:00

exec: proper handling of empty headers for exec_bash_safety

(cherry picked from commit ae491ab355f0b2441bc20060154107b9163597de)

---

Modified: modules/exec/exec_hf.c

---

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

---

diff --git a/modules/exec/exec_hf.c b/modules/exec/exec_hf.c
index bed4541..bbdbaaf 100644
--- a/modules/exec/exec_hf.c
+++ b/modules/exec/exec_hf.c
@@ -258,8 +258,8 @@ static int print_hf_var(struct hf_wrapper *w, int offset)
 	memcpy(envvar, w->prefix, w->prefix_len); c=envvar+w->prefix_len;
 	memcpy(c, hname, hlen ); c+=hlen;
 	*c=EV_ASSIGN;c++;
-	if (exec_bash_safety && !strncmp(w->u.hf->body.s, "() {",
-				MIN(w->u.hf->body.len,4))) {
+	if (exec_bash_safety && w->u.hf->body.len>=4
+			&& !strncmp(w->u.hf->body.s, "() {", 4)) {
 		memcpy(c, w->u.hf->body.s+offset+2, w->u.hf->body.len-2 );
 		c+=(w->u.hf->body.len-2);
 	} else {
@@ -268,8 +268,8 @@ static int print_hf_var(struct hf_wrapper *w, int offset)
 	}
 	for(wi=w->next_same; wi; wi=wi->next_same) {
 		*c=HF_SEPARATOR;c++;
-		if (exec_bash_safety && !strncmp(wi->u.hf->body.s, "() {",
-					MIN(w->u.hf->body.len,4))) {
+		if (exec_bash_safety && wi->u.hf->body.len>=4
+				&& !strncmp(wi->u.hf->body.s, "() {", 4)) {
 			memcpy(c, wi->u.hf->body.s+offset+2, wi->u.hf->body.len-2 );
 			c+=(wi->u.hf->body.len-2);
 		} else {




More information about the sr-dev mailing list