Przeglądaj źródła

exec: proper handling of empty headers for exec_bash_safety

Daniel-Constantin Mierla 10 lat temu
rodzic
commit
ae491ab355
1 zmienionych plików z 4 dodań i 4 usunięć
  1. 4 4
      modules/exec/exec_hf.c

+ 4 - 4
modules/exec/exec_hf.c

@@ -256,8 +256,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(envvar, w->prefix, w->prefix_len); c=envvar+w->prefix_len;
 	memcpy(c, hname, hlen ); c+=hlen;
 	memcpy(c, hname, hlen ); c+=hlen;
 	*c=EV_ASSIGN;c++;
 	*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 );
 		memcpy(c, w->u.hf->body.s+offset+2, w->u.hf->body.len-2 );
 		c+=(w->u.hf->body.len-2);
 		c+=(w->u.hf->body.len-2);
 	} else {
 	} else {
@@ -266,8 +266,8 @@ static int print_hf_var(struct hf_wrapper *w, int offset)
 	}
 	}
 	for(wi=w->next_same; wi; wi=wi->next_same) {
 	for(wi=w->next_same; wi; wi=wi->next_same) {
 		*c=HF_SEPARATOR;c++;
 		*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 );
 			memcpy(c, wi->u.hf->body.s+offset+2, wi->u.hf->body.len-2 );
 			c+=(wi->u.hf->body.len-2);
 			c+=(wi->u.hf->body.len-2);
 		} else {
 		} else {