Merge remote-tracking branch 'origin/topic/vern/zam-assert-fix'

* origin/topic/vern/zam-assert-fix:
  fix for ZAM "assert" statements potentially evaluating invalid expressions
This commit is contained in:
Arne Welzel 2024-12-06 10:22:07 +01:00
commit 2f27db6542
5 changed files with 15 additions and 4 deletions

View file

@ -1,3 +1,7 @@
7.1.0-dev.692 | 2024-12-06 10:22:07 +0100
* fix for ZAM "assert" statements potentially evaluating invalid expressions (Vern Paxson, Corelight)
7.1.0-dev.689 | 2024-12-05 13:48:46 -0700 7.1.0-dev.689 | 2024-12-05 13:48:46 -0700
* init-bare: Deprecate tcp_reassembler_ports (Arne Welzel, Corelight) * init-bare: Deprecate tcp_reassembler_ports (Arne Welzel, Corelight)

View file

@ -1 +1 @@
7.1.0-dev.689 7.1.0-dev.692

View file

@ -1062,6 +1062,9 @@ const ZAMStmt ZAMCompiler::CompileAssert(const AssertStmt* as) {
(void)AddInst(ZInstI(OP_SHOULD_REPORT_ASSERT_VV, decision_slot, cond_slot)); (void)AddInst(ZInstI(OP_SHOULD_REPORT_ASSERT_VV, decision_slot, cond_slot));
auto cond_stmt = AddInst(ZInstI(OP_IF_Vb, decision_slot, 0));
AddCFT(insts1.back(), CFT_IF);
ZInstI z; ZInstI z;
// We don't have a convenient way of directly introducing a std::string // We don't have a convenient way of directly introducing a std::string
@ -1085,7 +1088,11 @@ const ZAMStmt ZAMCompiler::CompileAssert(const AssertStmt* as) {
else else
z = ZInstI(OP_REPORT_ASSERT_VVC, decision_slot, cond_slot, cond_desc_e.get()); z = ZInstI(OP_REPORT_ASSERT_VVC, decision_slot, cond_slot, cond_desc_e.get());
return AddInst(z); auto end_inst = AddInst(z);
AddCFT(insts1.back(), CFT_BLOCK_END);
SetV(cond_stmt, GoToTargetBeyond(end_inst), 2);
return end_inst;
} }
const ZAMStmt ZAMCompiler::InitRecord(IDPtr id, RecordType* rt) { const ZAMStmt ZAMCompiler::InitRecord(IDPtr id, RecordType* rt) {

View file

@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
runtime error in <...>/assert.zeek, line 9: field value missing: $b error in <...>/assert.zeek, line 10: assertion failure: r?$b (r$b is not set in [a=1234, b=<uninitialized>])
fatal error: errors occurred while initializing fatal error: errors occurred while initializing

View file

@ -1,3 +1,3 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63. ### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
runtime error in <...>/assert.zeek, line 9: field value missing: $b runtime error in <...>/assert.zeek, line 12: field value missing: $b
fatal error: errors occurred while initializing fatal error: errors occurred while initializing