]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Fix typecheck for AND/OR.
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 7 Jan 2020 00:24:30 +0000 (01:24 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Tue, 7 Jan 2020 00:24:30 +0000 (01:24 +0100)
Do not apply dynamic type check for second argument of AND/OR, as it is
not evaluated immediately like regular argument would be.

Thanks to Mikael for the bugreport.

filter/decl.m4
filter/f-inst.c

index a78450a353adc764e32eb4b2f70097b8130a48d0..efecb9a57e6f9e4468c92826a2c98ab785fb70ca 100644 (file)
@@ -161,11 +161,16 @@ FID_HIC(,[[
 
 #      Some arguments need to check their type. After that, ARG_ANY is called.
 m4_define(ARG, `ARG_ANY($1) ARG_TYPE($1,$2)')
-m4_define(ARG_TYPE, `
+m4_define(ARG_TYPE, `ARG_TYPE_STATIC($1,$2) ARG_TYPE_DYNAMIC($1,$2)')
+
+m4_define(ARG_TYPE_STATIC, `
 FID_NEW_BODY()m4_dnl
 if (f$1->type && (f$1->type != ($2)) && !f_const_promotion(f$1, ($2)))
   cf_error("Argument $1 of %s must be of type %s, got type %s",
           f_instruction_name(what->fi_code), f_type_name($2), f_type_name(f$1->type));
+FID_INTERPRET_BODY()')
+
+m4_define(ARG_TYPE_DYNAMIC, `
 FID_INTERPRET_EXEC()m4_dnl
 if (v$1.type != ($2))
   runtime("Argument $1 of %s must be of type %s, got type %s",
index 51a35350986adaa7e09621b0e0326183f2c54b35..4b3c627b57b802e2e6b8ce4e514530b1b2c2be41 100644 (file)
   }
   INST(FI_AND, 1, 1) {
     ARG(1,T_BOOL);
-    ARG_TYPE(2,T_BOOL);
+    ARG_TYPE_STATIC(2,T_BOOL);
     RESULT_TYPE(T_BOOL);
 
     if (v1.val.i)
   }
   INST(FI_OR, 1, 1) {
     ARG(1,T_BOOL);
-    ARG_TYPE(2,T_BOOL);
+    ARG_TYPE_STATIC(2,T_BOOL);
     RESULT_TYPE(T_BOOL);
 
     if (!v1.val.i)