[sr-dev] git:4.2: exec: use proper header field iterator to print env variables

Daniel-Constantin Mierla miconda at gmail.com
Sat Dec 6 00:25:54 CET 2014


Module: sip-router
Branch: 4.2
Commit: db8859587bb5b97637e1f815ab631fc42e8d49c9
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=db8859587bb5b97637e1f815ab631fc42e8d49c9

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Fri Dec  5 22:40:25 2014 +0100

exec: use proper header field iterator to print env variables

- issue introduced with the patch for shellshock
- reported by and credits for troubleshooting to Kristian Kielhofner

(cherry picked from commit 8855e3e7fcece4ca2ab33e1f9c54b15831152400)

---

 modules/exec/exec_hf.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/modules/exec/exec_hf.c b/modules/exec/exec_hf.c
index bd7a3d4..bed4541 100644
--- a/modules/exec/exec_hf.c
+++ b/modules/exec/exec_hf.c
@@ -258,21 +258,23 @@ 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 && !strncmp(w->u.hf->body.s, "() {",
+				MIN(w->u.hf->body.len,4))) {
 		memcpy(c, w->u.hf->body.s+offset+2, w->u.hf->body.len-2 );
 		c+=(w->u.hf->body.len-2);
 	} else {
 		memcpy(c, w->u.hf->body.s+offset, w->u.hf->body.len );
 		c+=w->u.hf->body.len;
 	}
-	for (wi=w->next_same; wi; wi=wi->next_same) {
+	for(wi=w->next_same; wi; wi=wi->next_same) {
 		*c=HF_SEPARATOR;c++;
-		if (exec_bash_safety && !strncmp(w->u.hf->body.s,"() {",MIN(w->u.hf->body.len,4))) {
-			memcpy(c, w->u.hf->body.s+offset+2, w->u.hf->body.len-2 );
-			c+=(w->u.hf->body.len-2);
+		if (exec_bash_safety && !strncmp(wi->u.hf->body.s, "() {",
+					MIN(w->u.hf->body.len,4))) {
+			memcpy(c, wi->u.hf->body.s+offset+2, wi->u.hf->body.len-2 );
+			c+=(wi->u.hf->body.len-2);
 		} else {
-			memcpy(c, w->u.hf->body.s+offset, w->u.hf->body.len );
-			c+=w->u.hf->body.len;
+			memcpy(c, wi->u.hf->body.s+offset, wi->u.hf->body.len );
+			c+=wi->u.hf->body.len;
 		}
 	}
 	*c=0; /* zero termination */




More information about the sr-dev mailing list