mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
A handful of int-to-bool conversions
This commit is contained in:
parent
90d0bc64fa
commit
cd7ebdb2ed
5 changed files with 21 additions and 20 deletions
|
@ -929,7 +929,7 @@ bool CompositeHash::ReserveSingleTypeKeySize(HashKey& hk, Type* bt, const Val* v
|
||||||
{
|
{
|
||||||
reporter->InternalError(
|
reporter->InternalError(
|
||||||
"bad index type in CompositeHash::ReserveSingleTypeKeySize");
|
"bad index type in CompositeHash::ReserveSingleTypeKeySize");
|
||||||
return 0;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -335,8 +335,9 @@ zeek::RecordValPtr ICMPAnalyzer::ExtractICMP4Context(int len, const u_char*& dat
|
||||||
{
|
{
|
||||||
// We don't have an entire IP header.
|
// We don't have an entire IP header.
|
||||||
bad_hdr_len = true;
|
bad_hdr_len = true;
|
||||||
|
bad_checksum = false;
|
||||||
ip_len = frag_offset = 0;
|
ip_len = frag_offset = 0;
|
||||||
DF = MF = bad_checksum = 0;
|
DF = MF = 0;
|
||||||
src_port = dst_port = 0;
|
src_port = dst_port = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +371,7 @@ zeek::RecordValPtr ICMPAnalyzer::ExtractICMP4Context(int len, const u_char*& dat
|
||||||
// 4 above is the magic number meaning that both
|
// 4 above is the magic number meaning that both
|
||||||
// port numbers are included in the ICMP.
|
// port numbers are included in the ICMP.
|
||||||
src_port = dst_port = 0;
|
src_port = dst_port = 0;
|
||||||
bad_hdr_len = 1;
|
bad_hdr_len = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,7 +501,7 @@ void ICMPAnalyzer::RouterAdvert(double t, const struct icmp* icmpp, int len, int
|
||||||
int opt_offset = sizeof(reachable) + sizeof(retrans);
|
int opt_offset = sizeof(reachable) + sizeof(retrans);
|
||||||
|
|
||||||
adapter->EnqueueConnEvent(
|
adapter->EnqueueConnEvent(
|
||||||
f, adapter->ConnVal(), BuildInfo(icmpp, len, 1, ip_hdr),
|
f, adapter->ConnVal(), BuildInfo(icmpp, len, true, ip_hdr),
|
||||||
val_mgr->Count(icmpp->icmp_num_addrs), // Cur Hop Limit
|
val_mgr->Count(icmpp->icmp_num_addrs), // Cur Hop Limit
|
||||||
val_mgr->Bool(icmpp->icmp_wpa & 0x80), // Managed
|
val_mgr->Bool(icmpp->icmp_wpa & 0x80), // Managed
|
||||||
val_mgr->Bool(icmpp->icmp_wpa & 0x40), // Other
|
val_mgr->Bool(icmpp->icmp_wpa & 0x40), // Other
|
||||||
|
@ -530,7 +531,7 @@ void ICMPAnalyzer::NeighborAdvert(double t, const struct icmp* icmpp, int len, i
|
||||||
|
|
||||||
int opt_offset = sizeof(in6_addr);
|
int opt_offset = sizeof(in6_addr);
|
||||||
|
|
||||||
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, 1, ip_hdr),
|
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, true, ip_hdr),
|
||||||
val_mgr->Bool(icmpp->icmp_num_addrs & 0x80), // Router
|
val_mgr->Bool(icmpp->icmp_num_addrs & 0x80), // Router
|
||||||
val_mgr->Bool(icmpp->icmp_num_addrs & 0x40), // Solicited
|
val_mgr->Bool(icmpp->icmp_num_addrs & 0x40), // Solicited
|
||||||
val_mgr->Bool(icmpp->icmp_num_addrs & 0x20), // Override
|
val_mgr->Bool(icmpp->icmp_num_addrs & 0x20), // Override
|
||||||
|
@ -554,7 +555,7 @@ void ICMPAnalyzer::NeighborSolicit(double t, const struct icmp* icmpp, int len,
|
||||||
|
|
||||||
int opt_offset = sizeof(in6_addr);
|
int opt_offset = sizeof(in6_addr);
|
||||||
|
|
||||||
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, 1, ip_hdr),
|
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, true, ip_hdr),
|
||||||
make_intrusive<AddrVal>(tgtaddr),
|
make_intrusive<AddrVal>(tgtaddr),
|
||||||
BuildNDOptionsVal(caplen - opt_offset, data + opt_offset, adapter));
|
BuildNDOptionsVal(caplen - opt_offset, data + opt_offset, adapter));
|
||||||
}
|
}
|
||||||
|
@ -577,7 +578,7 @@ void ICMPAnalyzer::Redirect(double t, const struct icmp* icmpp, int len, int cap
|
||||||
|
|
||||||
int opt_offset = 2 * sizeof(in6_addr);
|
int opt_offset = 2 * sizeof(in6_addr);
|
||||||
|
|
||||||
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, 1, ip_hdr),
|
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, true, ip_hdr),
|
||||||
make_intrusive<AddrVal>(tgtaddr), make_intrusive<AddrVal>(dstaddr),
|
make_intrusive<AddrVal>(tgtaddr), make_intrusive<AddrVal>(dstaddr),
|
||||||
BuildNDOptionsVal(caplen - opt_offset, data + opt_offset, adapter));
|
BuildNDOptionsVal(caplen - opt_offset, data + opt_offset, adapter));
|
||||||
}
|
}
|
||||||
|
@ -591,7 +592,7 @@ void ICMPAnalyzer::RouterSolicit(double t, const struct icmp* icmpp, int len, in
|
||||||
if ( ! f )
|
if ( ! f )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, 1, ip_hdr),
|
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, true, ip_hdr),
|
||||||
BuildNDOptionsVal(caplen, data, adapter));
|
BuildNDOptionsVal(caplen, data, adapter));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -612,7 +613,7 @@ void ICMPAnalyzer::Context4(double t, const struct icmp* icmpp, int len, int cap
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( f )
|
if ( f )
|
||||||
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, 0, ip_hdr),
|
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, false, ip_hdr),
|
||||||
val_mgr->Count(icmpp->icmp_code),
|
val_mgr->Count(icmpp->icmp_code),
|
||||||
ExtractICMP4Context(caplen, data));
|
ExtractICMP4Context(caplen, data));
|
||||||
}
|
}
|
||||||
|
@ -646,7 +647,7 @@ void ICMPAnalyzer::Context6(double t, const struct icmp* icmpp, int len, int cap
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( f )
|
if ( f )
|
||||||
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, 1, ip_hdr),
|
adapter->EnqueueConnEvent(f, adapter->ConnVal(), BuildInfo(icmpp, len, true, ip_hdr),
|
||||||
val_mgr->Count(icmpp->icmp_code),
|
val_mgr->Count(icmpp->icmp_code),
|
||||||
ExtractICMP6Context(caplen, data));
|
ExtractICMP6Context(caplen, data));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2033,7 +2033,7 @@ case_type_list:
|
||||||
case_type:
|
case_type:
|
||||||
TOK_TYPE type
|
TOK_TYPE type
|
||||||
{
|
{
|
||||||
$$ = new ID(0, SCOPE_FUNCTION, 0);
|
$$ = new ID(0, SCOPE_FUNCTION, false);
|
||||||
$$->SetType({AdoptRef{}, $2});
|
$$->SetType({AdoptRef{}, $2});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2164,17 +2164,17 @@ local_id:
|
||||||
;
|
;
|
||||||
|
|
||||||
global_id:
|
global_id:
|
||||||
{ resolving_global_ID = 1; } global_or_event_id
|
{ resolving_global_ID = true; } global_or_event_id
|
||||||
{ $$ = $2; }
|
{ $$ = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
def_global_id:
|
def_global_id:
|
||||||
{ defining_global_ID = 1; } global_id { defining_global_ID = 0; }
|
{ defining_global_ID = true; } global_id { defining_global_ID = false; }
|
||||||
{ $$ = $2; }
|
{ $$ = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
event_id:
|
event_id:
|
||||||
{ resolving_global_ID = 0; } global_or_event_id
|
{ resolving_global_ID = false; } global_or_event_id
|
||||||
{ $$ = $2; }
|
{ $$ = $2; }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -220,16 +220,16 @@ rule_attr:
|
||||||
}
|
}
|
||||||
|
|
||||||
| TOK_REQUIRES_SIGNATURE TOK_IDENT
|
| TOK_REQUIRES_SIGNATURE TOK_IDENT
|
||||||
{ current_rule->AddRequires($2, 0, 0); }
|
{ current_rule->AddRequires($2, false, false); }
|
||||||
|
|
||||||
| TOK_REQUIRES_SIGNATURE '!' TOK_IDENT
|
| TOK_REQUIRES_SIGNATURE '!' TOK_IDENT
|
||||||
{ current_rule->AddRequires($3, 0, 1); }
|
{ current_rule->AddRequires($3, false, true); }
|
||||||
|
|
||||||
| TOK_REQUIRES_REVERSE_SIGNATURE TOK_IDENT
|
| TOK_REQUIRES_REVERSE_SIGNATURE TOK_IDENT
|
||||||
{ current_rule->AddRequires($2, 1, 0); }
|
{ current_rule->AddRequires($2, true, false); }
|
||||||
|
|
||||||
| TOK_REQUIRES_REVERSE_SIGNATURE '!' TOK_IDENT
|
| TOK_REQUIRES_REVERSE_SIGNATURE '!' TOK_IDENT
|
||||||
{ current_rule->AddRequires($3, 1, 1); }
|
{ current_rule->AddRequires($3, true, true); }
|
||||||
|
|
||||||
| TOK_SAME_IP
|
| TOK_SAME_IP
|
||||||
{ current_rule->AddCondition(new zeek::detail::RuleConditionSameIP()); }
|
{ current_rule->AddCondition(new zeek::detail::RuleConditionSameIP()); }
|
||||||
|
|
|
@ -55,7 +55,7 @@ StringVal* ZAM_to_lower(const StringVal* sv)
|
||||||
|
|
||||||
*ls++ = '\0';
|
*ls++ = '\0';
|
||||||
|
|
||||||
return new StringVal(new String(1, lower_s, n));
|
return new StringVal(new String(true, lower_s, n));
|
||||||
}
|
}
|
||||||
|
|
||||||
StringVal* ZAM_sub_bytes(const StringVal* s, zeek_uint_t start, zeek_int_t n)
|
StringVal* ZAM_sub_bytes(const StringVal* s, zeek_uint_t start, zeek_int_t n)
|
||||||
|
@ -76,7 +76,7 @@ StringValPtr ZAM_val_cat(const ValPtr& v)
|
||||||
|
|
||||||
v->Describe(&d);
|
v->Describe(&d);
|
||||||
|
|
||||||
String* s = new String(1, d.TakeBytes(), d.Len());
|
String* s = new String(true, d.TakeBytes(), d.Len());
|
||||||
s->SetUseFreeToDelete(true);
|
s->SetUseFreeToDelete(true);
|
||||||
|
|
||||||
return make_intrusive<StringVal>(s);
|
return make_intrusive<StringVal>(s);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue