From b3b5a731138c4d117d16179106691e8d034d7e8b Mon Sep 17 00:00:00 2001 From: Robin Sommer Date: Tue, 19 Apr 2011 16:21:13 -0700 Subject: [PATCH] Fixing problem with optional fields. --- aux/binpac | 2 +- aux/bro-aux | 2 +- aux/broccoli | 2 +- aux/broctl | 2 +- aux/btest | 2 +- src/Val.cc | 1 - .../Baseline/language.rec-nested-opt/output | 3 +++ .../btest/Baseline/logging.rotate-custom/out | 4 +-- testing/btest/language/rec-nested-opt.bro | 25 +++++++++++++++++++ 9 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 testing/btest/Baseline/language.rec-nested-opt/output create mode 100644 testing/btest/language/rec-nested-opt.bro diff --git a/aux/binpac b/aux/binpac index c3c7ef0dfd..26d02716f9 160000 --- a/aux/binpac +++ b/aux/binpac @@ -1 +1 @@ -Subproject commit c3c7ef0dfddb0746d3762e41086ba42928e68483 +Subproject commit 26d02716f9090651f319a4bfdf8ede49b3a7b53a diff --git a/aux/bro-aux b/aux/bro-aux index 98f92eeb40..7e50bac938 160000 --- a/aux/bro-aux +++ b/aux/bro-aux @@ -1 +1 @@ -Subproject commit 98f92eeb40281045159097764abddc428fb49bf2 +Subproject commit 7e50bac938af1831ecf9660159145a3c2e77e13d diff --git a/aux/broccoli b/aux/broccoli index 48d473398e..9332ab3467 160000 --- a/aux/broccoli +++ b/aux/broccoli @@ -1 +1 @@ -Subproject commit 48d473398e577893b6c7f77d605ccdf266a2f93b +Subproject commit 9332ab3467191ac22be09d6941ebd469e7a334d0 diff --git a/aux/broctl b/aux/broctl index 532dcd5aa5..06b74a0f23 160000 --- a/aux/broctl +++ b/aux/broctl @@ -1 +1 @@ -Subproject commit 532dcd5aa51c8b29b2d71cd37e1d7c21e33cc715 +Subproject commit 06b74a0f23767c8345ed146657120aba812f6764 diff --git a/aux/btest b/aux/btest index 409bda3a00..b29e2214cc 160000 --- a/aux/btest +++ b/aux/btest @@ -1 +1 @@ -Subproject commit 409bda3a003b18c4736ef168595f20118f4d0038 +Subproject commit b29e2214cc959b6b6c841497b7881df369331561 diff --git a/src/Val.cc b/src/Val.cc index 2b086ccec3..ce639e3d0d 100644 --- a/src/Val.cc +++ b/src/Val.cc @@ -2955,7 +2955,6 @@ RecordVal* RecordVal::CoerceTo(const RecordType* t, Val* aggr) const Expr* rhs = new ConstExpr(Lookup(i)->Ref()); Expr* e = new RecordCoerceExpr(rhs, ar_t->FieldType(t_i)->AsRecordType()); ar->Assign(t_i, e->Eval(0)); - break; } ar->Assign(t_i, Lookup(i)->Ref()); diff --git a/testing/btest/Baseline/language.rec-nested-opt/output b/testing/btest/Baseline/language.rec-nested-opt/output new file mode 100644 index 0000000000..e41358b71d --- /dev/null +++ b/testing/btest/Baseline/language.rec-nested-opt/output @@ -0,0 +1,3 @@ +{ +[Wget/1.9+cvs-stable (Red Hat modified)] = [name=Wget, version=[major=1, minor=9, addl=+cvs], host=0.0.0.0, ts=0.0] +} diff --git a/testing/btest/Baseline/logging.rotate-custom/out b/testing/btest/Baseline/logging.rotate-custom/out index e270b6a773..8206ec5f9a 100644 --- a/testing/btest/Baseline/logging.rotate-custom/out +++ b/testing/btest/Baseline/logging.rotate-custom/out @@ -68,6 +68,8 @@ # t id.orig_h id.orig_p id.resp_h id.resp_p 1299499205.0 10.0.0.1 20 10.0.0.2 1033 1299502795.0 10.0.0.2 20 10.0.0.3 9 +> test.log +# t id.orig_h id.orig_p id.resp_h id.resp_p > test2-11-03-06_19.00.05.log # t id.orig_h id.orig_p id.resp_h id.resp_p 1299466805.0 10.0.0.1 20 10.0.0.2 1024 @@ -130,5 +132,3 @@ 1299502795.0 10.0.0.2 20 10.0.0.3 9 > test2.log # t id.orig_h id.orig_p id.resp_h id.resp_p -> test.log -# t id.orig_h id.orig_p id.resp_h id.resp_p diff --git a/testing/btest/language/rec-nested-opt.bro b/testing/btest/language/rec-nested-opt.bro new file mode 100644 index 0000000000..eb7375541b --- /dev/null +++ b/testing/btest/language/rec-nested-opt.bro @@ -0,0 +1,25 @@ + +# @TEST-EXEC: bro %INPUT >output 2>&1 +# @TEST-EXEC: btest-diff output + +type Version: record { + major: count &optional; ##< Major version number + minor: count &optional; ##< Minor version number + addl: string &optional; ##< Additional version string (e.g. "beta42") +} &log; + +type Info: record { + name: string; + version: Version; + host: addr; + ts: time; +}; + + +# Important thing to note here is that $minor2 is not include in the $version field. +global matched_software: table[string] of Info = { + ["Wget/1.9+cvs-stable (Red Hat modified)"] = + [$name="Wget", $version=[$major=1,$minor=9,$addl="+cvs"], $host=0.0.0.0, $ts=network_time()], +}; + +print matched_software;