[sr-dev] git:sr_3.0: cfg parser: segfault on case RE parse error fix

Andrei Pelinescu-Onciul andrei at iptel.org
Thu Mar 4 10:25:53 CET 2010


Module: sip-router
Branch: sr_3.0
Commit: 6399e063ded46868e3819436685ce9afc8bcd831
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=6399e063ded46868e3819436685ce9afc8bcd831

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Wed Feb 24 15:13:12 2010 +0100

cfg parser: segfault on case RE parse error fix

Reported-by: Klaus Feichtinger  klaus.feichtinger gmx net
(cherry picked from commit d2871c1190291e4b801f42e0763e5ca7ea28ee36)

---

 cfg.y |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/cfg.y b/cfg.y
index 2ca76bb..bfaff5f 100644
--- a/cfg.y
+++ b/cfg.y
@@ -2239,12 +2239,14 @@ if_cmd:
 
 ct_rval: rval_expr {
 			$$=0;
-			if (!rve_is_constant($1)){
+			if ($1 && !rve_is_constant($1)){
 				yyerror("constant expected");
+				YYERROR;
 			/*
-			} else if (!rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){
+			} else if ($1 &&
+						!rve_check_type((enum rval_type*)&i_tmp, $1, 0, 0 ,0)){
 				yyerror("invalid expression (bad type)");
-			}else if (i_tmp!=RV_INT){
+			}else if ($1 && i_tmp!=RV_INT){
 				yyerror("invalid expression type, int expected\n");
 			*/
 			}else
@@ -2254,28 +2256,28 @@ ct_rval: rval_expr {
 single_case:
 	CASE ct_rval COLON actions {
 		$$=0;
-		if ($2==0) yyerror ("bad case label");
+		if ($2==0) { yyerror ("bad case label"); YYERROR; }
 		else if ((($$=mk_case_stm($2, 0, $4, &i_tmp))==0) && (i_tmp==-10)){
 				YYABORT;
 		}
 	}
 | CASE SLASH ct_rval COLON actions {
 		$$=0;
-		if ($3==0) yyerror ("bad case label");
+		if ($3==0) { yyerror ("bad case label"); YYERROR; }
 		else if ((($$=mk_case_stm($3, 1, $5, &i_tmp))==0) && (i_tmp==-10)){
 				YYABORT;
 		}
 	}
 	| CASE ct_rval COLON {
 		$$=0;
-		if ($2==0) yyerror ("bad case label");
+		if ($2==0) { yyerror ("bad case label"); YYERROR; }
 		else if ((($$=mk_case_stm($2, 0, 0, &i_tmp))==0) && (i_tmp==-10)){
 				YYABORT;
 		}
 	}
 	| CASE SLASH ct_rval COLON {
 		$$=0;
-		if ($3==0) yyerror ("bad case label");
+		if ($3==0) { yyerror ("bad regex case label"); YYERROR; }
 		else if ((($$=mk_case_stm($3, 1, 0, &i_tmp))==0) && (i_tmp==-10)){
 				YYABORT;
 		}
@@ -2290,7 +2292,10 @@ single_case:
 				YYABORT;
 		}
 	}
-	| CASE error { $$=0; yyerror("bad case label"); }
+	| CASE error COLON actions { $$=0; yyerror("bad case label"); }
+	| CASE SLASH error COLON actions { $$=0; yyerror("bad case regex label"); }
+	| CASE error COLON { $$=0; yyerror("bad case label"); }
+	| CASE SLASH error COLON { $$=0; yyerror("bad case regex label"); }
 	| CASE ct_rval COLON error { $$=0; yyerror ("bad case body"); }
 ;
 case_stms:




More information about the sr-dev mailing list