mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
clang-format: Set IndentCaseBlocks to false
This commit is contained in:
parent
02206f3215
commit
4423574d26
58 changed files with 4729 additions and 4766 deletions
|
@ -47,7 +47,7 @@ ColumnLimit: 100
|
||||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
FixNamespaceComments: false
|
FixNamespaceComments: false
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
IndentCaseBlocks: true
|
IndentCaseBlocks: false
|
||||||
IndentExternBlock: NoIndent
|
IndentExternBlock: NoIndent
|
||||||
IndentPPDirectives: None
|
IndentPPDirectives: None
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
|
|
13
src/Attr.cc
13
src/Attr.cc
|
@ -331,8 +331,8 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
FuncType* aft = at->AsFuncType();
|
FuncType* aft = at->AsFuncType();
|
||||||
if ( ! same_type(aft->Yield(), type) )
|
if ( ! same_type(aft->Yield(), type) )
|
||||||
{
|
{
|
||||||
a->GetExpr()->Error(
|
a->GetExpr()->Error(is_add
|
||||||
is_add ? "&add_func function must yield same type as variable"
|
? "&add_func function must yield same type as variable"
|
||||||
: "&delete_func function must yield same type as variable");
|
: "&delete_func function must yield same type as variable");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -359,8 +359,7 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
|
|
||||||
// Record defaults may be promotable.
|
// Record defaults may be promotable.
|
||||||
if ( (type->Tag() == TYPE_RECORD && atype->Tag() == TYPE_RECORD &&
|
if ( (type->Tag() == TYPE_RECORD && atype->Tag() == TYPE_RECORD &&
|
||||||
record_promotion_compatible(atype->AsRecordType(),
|
record_promotion_compatible(atype->AsRecordType(), type->AsRecordType())) )
|
||||||
type->AsRecordType())) )
|
|
||||||
// Ok.
|
// Ok.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -393,8 +392,7 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
if ( atype->Tag() == TYPE_FUNC )
|
if ( atype->Tag() == TYPE_FUNC )
|
||||||
{
|
{
|
||||||
FuncType* f = atype->AsFuncType();
|
FuncType* f = atype->AsFuncType();
|
||||||
if ( ! f->CheckArgs(tt->GetIndexTypes()) ||
|
if ( ! f->CheckArgs(tt->GetIndexTypes()) || ! same_type(f->Yield(), ytype) )
|
||||||
! same_type(f->Yield(), ytype) )
|
|
||||||
Error("&default function type clash");
|
Error("&default function type clash");
|
||||||
|
|
||||||
// Ok.
|
// Ok.
|
||||||
|
@ -432,8 +430,7 @@ void Attributes::CheckAttr(Attr* a)
|
||||||
// Ok.
|
// Ok.
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if ( (atype->Tag() == TYPE_TABLE &&
|
if ( (atype->Tag() == TYPE_TABLE && atype->AsTableType()->IsUnspecifiedTable()) )
|
||||||
atype->AsTableType()->IsUnspecifiedTable()) )
|
|
||||||
{
|
{
|
||||||
auto e = check_and_promote_expr(a->GetExpr(), type);
|
auto e = check_and_promote_expr(a->GetExpr(), type);
|
||||||
|
|
||||||
|
|
|
@ -263,8 +263,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
||||||
const auto& f = Func::GetFuncPtrByID(id);
|
const auto& f = Func::GetFuncPtrByID(id);
|
||||||
|
|
||||||
if ( ! f )
|
if ( ! f )
|
||||||
reporter->InternalError(
|
reporter->InternalError("failed to look up unique function id %" PRIu32
|
||||||
"failed to look up unique function id %" PRIu32
|
|
||||||
" in CompositeHash::RecoverOneVal()",
|
" in CompositeHash::RecoverOneVal()",
|
||||||
id);
|
id);
|
||||||
|
|
||||||
|
@ -314,8 +313,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
||||||
RE_Matcher* re = new RE_Matcher(texts[0], texts[1]);
|
RE_Matcher* re = new RE_Matcher(texts[0], texts[1]);
|
||||||
|
|
||||||
if ( ! re->Compile() )
|
if ( ! re->Compile() )
|
||||||
reporter->InternalError(
|
reporter->InternalError("failed compiling table/set key pattern: %s",
|
||||||
"failed compiling table/set key pattern: %s",
|
|
||||||
re->PatternText());
|
re->PatternText());
|
||||||
|
|
||||||
*pval = make_intrusive<PatternVal>(re);
|
*pval = make_intrusive<PatternVal>(re);
|
||||||
|
@ -335,8 +333,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
||||||
Attributes* a = rt->FieldDecl(i)->attrs.get();
|
Attributes* a = rt->FieldDecl(i)->attrs.get();
|
||||||
bool optional = (a && a->Find(ATTR_OPTIONAL));
|
bool optional = (a && a->Find(ATTR_OPTIONAL));
|
||||||
|
|
||||||
if ( ! RecoverOneVal(hk, rt->GetFieldType(i).get(), &v, optional,
|
if ( ! RecoverOneVal(hk, rt->GetFieldType(i).get(), &v, optional, false) )
|
||||||
false) )
|
|
||||||
{
|
{
|
||||||
*pval = nullptr;
|
*pval = nullptr;
|
||||||
return false;
|
return false;
|
||||||
|
@ -378,8 +375,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
||||||
for ( int i = 0; i < n; ++i )
|
for ( int i = 0; i < n; ++i )
|
||||||
{
|
{
|
||||||
ValPtr key;
|
ValPtr key;
|
||||||
if ( ! RecoverOneVal(hk, tt->GetIndices().get(), &key, false,
|
if ( ! RecoverOneVal(hk, tt->GetIndices().get(), &key, false, false) )
|
||||||
false) )
|
|
||||||
{
|
{
|
||||||
*pval = nullptr;
|
*pval = nullptr;
|
||||||
return false;
|
return false;
|
||||||
|
@ -390,8 +386,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ValPtr value;
|
ValPtr value;
|
||||||
if ( ! RecoverOneVal(hk, tt->Yield().get(), &value, false,
|
if ( ! RecoverOneVal(hk, tt->Yield().get(), &value, false, false) )
|
||||||
false) )
|
|
||||||
{
|
{
|
||||||
*pval = nullptr;
|
*pval = nullptr;
|
||||||
return false;
|
return false;
|
||||||
|
@ -455,8 +450,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
reporter->InternalError(
|
reporter->InternalError("bad index type in CompositeHash::RecoverOneVal");
|
||||||
"bad index type in CompositeHash::RecoverOneVal");
|
|
||||||
*pval = nullptr;
|
*pval = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -474,8 +468,7 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
||||||
hk.EnsureReadSpace(n);
|
hk.EnsureReadSpace(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
*pval =
|
*pval = make_intrusive<StringVal>(new String((const byte_vec)hk.KeyAtRead(), n, true));
|
||||||
make_intrusive<StringVal>(new String((const byte_vec)hk.KeyAtRead(), n, true));
|
|
||||||
hk.SkipRead("string", n);
|
hk.SkipRead("string", n);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -569,10 +562,8 @@ bool CompositeHash::SingleValHash(HashKey& hk, const Val* v, Type* bt, bool type
|
||||||
hk.Allocate();
|
hk.Allocate();
|
||||||
}
|
}
|
||||||
|
|
||||||
hk.Write("pattern-string1", static_cast<const void*>(texts[0]),
|
hk.Write("pattern-string1", static_cast<const void*>(texts[0]), lens[0]);
|
||||||
lens[0]);
|
hk.Write("pattern-string2", static_cast<const void*>(texts[1]), lens[1]);
|
||||||
hk.Write("pattern-string2", static_cast<const void*>(texts[1]),
|
|
||||||
lens[1]);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,8 +586,8 @@ bool CompositeHash::SingleValHash(HashKey& hk, const Val* v, Type* bt, bool type
|
||||||
if ( ! (rv_i || optional_attr) )
|
if ( ! (rv_i || optional_attr) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( ! SingleValHash(hk, rv_i.get(), rt->GetFieldType(i).get(),
|
if ( ! SingleValHash(hk, rv_i.get(), rt->GetFieldType(i).get(), type_check,
|
||||||
type_check, optional_attr, false) )
|
optional_attr, false) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -616,16 +607,16 @@ bool CompositeHash::SingleValHash(HashKey& hk, const Val* v, Type* bt, bool type
|
||||||
{
|
{
|
||||||
auto key = kv.second;
|
auto key = kv.second;
|
||||||
|
|
||||||
if ( ! SingleValHash(hk, key.get(), key->GetType().get(),
|
if ( ! SingleValHash(hk, key.get(), key->GetType().get(), type_check, false,
|
||||||
type_check, false, false) )
|
false) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( ! v->GetType()->IsSet() )
|
if ( ! v->GetType()->IsSet() )
|
||||||
{
|
{
|
||||||
auto val = const_cast<TableVal*>(tv)->FindOrDefault(key);
|
auto val = const_cast<TableVal*>(tv)->FindOrDefault(key);
|
||||||
|
|
||||||
if ( ! SingleValHash(hk, val.get(), val->GetType().get(),
|
if ( ! SingleValHash(hk, val.get(), val->GetType().get(), type_check,
|
||||||
type_check, false, false) )
|
false, false) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -648,8 +639,8 @@ bool CompositeHash::SingleValHash(HashKey& hk, const Val* v, Type* bt, bool type
|
||||||
hk.Write("vector-idx", i);
|
hk.Write("vector-idx", i);
|
||||||
hk.Write("vector-idx-present", val != nullptr);
|
hk.Write("vector-idx-present", val != nullptr);
|
||||||
|
|
||||||
if ( val && ! SingleValHash(hk, val.get(), vt->Yield().get(),
|
if ( val && ! SingleValHash(hk, val.get(), vt->Yield().get(), type_check,
|
||||||
type_check, false, false) )
|
false, false) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,8 +664,8 @@ bool CompositeHash::SingleValHash(HashKey& hk, const Val* v, Type* bt, bool type
|
||||||
for ( int i = 0; i < lv->Length(); ++i )
|
for ( int i = 0; i < lv->Length(); ++i )
|
||||||
{
|
{
|
||||||
Val* entry_val = lv->Idx(i).get();
|
Val* entry_val = lv->Idx(i).get();
|
||||||
if ( ! SingleValHash(hk, entry_val, entry_val->GetType().get(),
|
if ( ! SingleValHash(hk, entry_val, entry_val->GetType().get(), type_check,
|
||||||
type_check, false, false) )
|
false, false) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,8 +673,7 @@ bool CompositeHash::SingleValHash(HashKey& hk, const Val* v, Type* bt, bool type
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
reporter->InternalError(
|
reporter->InternalError("bad index type in CompositeHash::SingleValHash");
|
||||||
"bad index type in CompositeHash::SingleValHash");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -804,10 +794,9 @@ bool CompositeHash::ReserveSingleTypeKeySize(HashKey& hk, Type* bt, const Val* v
|
||||||
}
|
}
|
||||||
|
|
||||||
// +1 in the following to include null terminators
|
// +1 in the following to include null terminators
|
||||||
hk.Reserve("pattern-string1", strlen(v->AsPattern()->PatternText()) + 1,
|
hk.Reserve("pattern-string1", strlen(v->AsPattern()->PatternText()) + 1, 0);
|
||||||
|
hk.Reserve("pattern-string1", strlen(v->AsPattern()->AnywherePatternText()) + 1,
|
||||||
0);
|
0);
|
||||||
hk.Reserve("pattern-string1",
|
|
||||||
strlen(v->AsPattern()->AnywherePatternText()) + 1, 0);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -826,9 +815,9 @@ bool CompositeHash::ReserveSingleTypeKeySize(HashKey& hk, Type* bt, const Val* v
|
||||||
bool optional_attr = (a && a->Find(ATTR_OPTIONAL));
|
bool optional_attr = (a && a->Find(ATTR_OPTIONAL));
|
||||||
|
|
||||||
auto rv_v = rv ? rv->GetField(i) : nullptr;
|
auto rv_v = rv ? rv->GetField(i) : nullptr;
|
||||||
if ( ! ReserveSingleTypeKeySize(
|
if ( ! ReserveSingleTypeKeySize(hk, rt->GetFieldType(i).get(), rv_v.get(),
|
||||||
hk, rt->GetFieldType(i).get(), rv_v.get(), type_check,
|
type_check, optional_attr, calc_static_size,
|
||||||
optional_attr, calc_static_size, false) )
|
false) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -856,9 +845,9 @@ bool CompositeHash::ReserveSingleTypeKeySize(HashKey& hk, Type* bt, const Val* v
|
||||||
if ( ! bt->IsSet() )
|
if ( ! bt->IsSet() )
|
||||||
{
|
{
|
||||||
auto val = const_cast<TableVal*>(tv)->FindOrDefault(key);
|
auto val = const_cast<TableVal*>(tv)->FindOrDefault(key);
|
||||||
if ( ! ReserveSingleTypeKeySize(hk, val->GetType().get(),
|
if ( ! ReserveSingleTypeKeySize(hk, val->GetType().get(), val.get(),
|
||||||
val.get(), type_check, false,
|
type_check, false, calc_static_size,
|
||||||
calc_static_size, false) )
|
false) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,8 +379,8 @@ const char* assign_to_index(ValPtr v1, ValPtr v2, ValPtr v3, bool& iterators_inv
|
||||||
auto vtt = vt->Tag();
|
auto vtt = vt->Tag();
|
||||||
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
|
std::string tn = vtt == TYPE_RECORD ? vt->GetName() : type_name(vtt);
|
||||||
return util::fmt(
|
return util::fmt(
|
||||||
"table index assignment failed for invalid type '%s', value: %s",
|
"table index assignment failed for invalid type '%s', value: %s", tn.data(),
|
||||||
tn.data(), d.Description());
|
d.Description());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return "assignment failed with null value";
|
return "assignment failed with null value";
|
||||||
|
|
|
@ -278,15 +278,14 @@ void Func::CheckPluginResult(bool handled, const ValPtr& hook_result, FunctionFl
|
||||||
if ( (! yt) || yt->Tag() == TYPE_VOID )
|
if ( (! yt) || yt->Tag() == TYPE_VOID )
|
||||||
{
|
{
|
||||||
if ( hook_result )
|
if ( hook_result )
|
||||||
reporter->InternalError(
|
reporter->InternalError("plugin returned non-void result for void method %s",
|
||||||
"plugin returned non-void result for void method %s", this->Name());
|
this->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() &&
|
else if ( hook_result && hook_result->GetType()->Tag() != yt->Tag() &&
|
||||||
yt->Tag() != TYPE_ANY )
|
yt->Tag() != TYPE_ANY )
|
||||||
{
|
{
|
||||||
reporter->InternalError(
|
reporter->InternalError("plugin returned wrong type (got %d, expecting %d) for %s",
|
||||||
"plugin returned wrong type (got %d, expecting %d) for %s",
|
|
||||||
hook_result->GetType()->Tag(), yt->Tag(), this->Name());
|
hook_result->GetType()->Tag(), yt->Tag(), this->Name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
30
src/IP.cc
30
src/IP.cc
|
@ -70,8 +70,7 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const
|
||||||
rv->Assign(5, make_intrusive<AddrVal>(IPAddr(ip6->ip6_src)));
|
rv->Assign(5, make_intrusive<AddrVal>(IPAddr(ip6->ip6_src)));
|
||||||
rv->Assign(6, make_intrusive<AddrVal>(IPAddr(ip6->ip6_dst)));
|
rv->Assign(6, make_intrusive<AddrVal>(IPAddr(ip6->ip6_dst)));
|
||||||
if ( ! chain )
|
if ( ! chain )
|
||||||
chain =
|
chain = make_intrusive<VectorVal>(id::find_type<VectorType>("ip6_ext_hdr_chain"));
|
||||||
make_intrusive<VectorVal>(id::find_type<VectorType>("ip6_ext_hdr_chain"));
|
|
||||||
rv->Assign(7, std::move(chain));
|
rv->Assign(7, std::move(chain));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -224,8 +223,8 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const
|
||||||
auto m = make_intrusive<RecordVal>(ip6_mob_hot_type);
|
auto m = make_intrusive<RecordVal>(ip6_mob_hot_type);
|
||||||
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
||||||
m->Assign(1, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))));
|
m->Assign(1, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))));
|
||||||
m->Assign(2, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) +
|
m->Assign(
|
||||||
sizeof(uint64_t)))));
|
2, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t)))));
|
||||||
off += sizeof(uint16_t) + 2 * sizeof(uint64_t);
|
off += sizeof(uint16_t) + 2 * sizeof(uint64_t);
|
||||||
m->Assign(3, BuildOptionsVal(data + off, Length() - off));
|
m->Assign(3, BuildOptionsVal(data + off, Length() - off));
|
||||||
msg->Assign(4, std::move(m));
|
msg->Assign(4, std::move(m));
|
||||||
|
@ -237,8 +236,8 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const
|
||||||
auto m = make_intrusive<RecordVal>(ip6_mob_cot_type);
|
auto m = make_intrusive<RecordVal>(ip6_mob_cot_type);
|
||||||
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
||||||
m->Assign(1, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))));
|
m->Assign(1, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))));
|
||||||
m->Assign(2, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) +
|
m->Assign(
|
||||||
sizeof(uint64_t)))));
|
2, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t)))));
|
||||||
off += sizeof(uint16_t) + 2 * sizeof(uint64_t);
|
off += sizeof(uint16_t) + 2 * sizeof(uint64_t);
|
||||||
m->Assign(3, BuildOptionsVal(data + off, Length() - off));
|
m->Assign(3, BuildOptionsVal(data + off, Length() - off));
|
||||||
msg->Assign(5, std::move(m));
|
msg->Assign(5, std::move(m));
|
||||||
|
@ -250,17 +249,13 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const
|
||||||
auto m = make_intrusive<RecordVal>(ip6_mob_bu_type);
|
auto m = make_intrusive<RecordVal>(ip6_mob_bu_type);
|
||||||
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
||||||
m->Assign(1, static_cast<bool>(
|
m->Assign(1, static_cast<bool>(
|
||||||
ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) &
|
ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x8000));
|
||||||
0x8000));
|
|
||||||
m->Assign(2, static_cast<bool>(
|
m->Assign(2, static_cast<bool>(
|
||||||
ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) &
|
ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x4000));
|
||||||
0x4000));
|
|
||||||
m->Assign(3, static_cast<bool>(
|
m->Assign(3, static_cast<bool>(
|
||||||
ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) &
|
ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x2000));
|
||||||
0x2000));
|
|
||||||
m->Assign(4, static_cast<bool>(
|
m->Assign(4, static_cast<bool>(
|
||||||
ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) &
|
ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x1000));
|
||||||
0x1000));
|
|
||||||
m->Assign(5, ntohs(*((uint16_t*)(msg_data + 2 * sizeof(uint16_t)))));
|
m->Assign(5, ntohs(*((uint16_t*)(msg_data + 2 * sizeof(uint16_t)))));
|
||||||
off += 3 * sizeof(uint16_t);
|
off += 3 * sizeof(uint16_t);
|
||||||
m->Assign(6, BuildOptionsVal(data + off, Length() - off));
|
m->Assign(6, BuildOptionsVal(data + off, Length() - off));
|
||||||
|
@ -272,8 +267,8 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const
|
||||||
{
|
{
|
||||||
auto m = make_intrusive<RecordVal>(ip6_mob_back_type);
|
auto m = make_intrusive<RecordVal>(ip6_mob_back_type);
|
||||||
m->Assign(0, *((uint8_t*)msg_data));
|
m->Assign(0, *((uint8_t*)msg_data));
|
||||||
m->Assign(1, static_cast<bool>(
|
m->Assign(1,
|
||||||
*((uint8_t*)(msg_data + sizeof(uint8_t))) & 0x80));
|
static_cast<bool>(*((uint8_t*)(msg_data + sizeof(uint8_t))) & 0x80));
|
||||||
m->Assign(2, ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))));
|
m->Assign(2, ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))));
|
||||||
m->Assign(3, ntohs(*((uint16_t*)(msg_data + 2 * sizeof(uint16_t)))));
|
m->Assign(3, ntohs(*((uint16_t*)(msg_data + 2 * sizeof(uint16_t)))));
|
||||||
off += 3 * sizeof(uint16_t);
|
off += 3 * sizeof(uint16_t);
|
||||||
|
@ -646,8 +641,7 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len)
|
||||||
// Double-check that the len can hold the whole option structure.
|
// Double-check that the len can hold the whole option structure.
|
||||||
// Otherwise we get a buffer-overflow when we check the option_len.
|
// Otherwise we get a buffer-overflow when we check the option_len.
|
||||||
// Also check that it holds everything for the option itself.
|
// Also check that it holds everything for the option itself.
|
||||||
if ( len < sizeof(struct ip6_opt) ||
|
if ( len < sizeof(struct ip6_opt) || len < sizeof(struct ip6_opt) + opt->ip6o_len )
|
||||||
len < sizeof(struct ip6_opt) + opt->ip6o_len )
|
|
||||||
{
|
{
|
||||||
reporter->Weird(SrcAddr(), DstAddr(), "bad_ipv6_dest_opt_len");
|
reporter->Weird(SrcAddr(), DstAddr(), "bad_ipv6_dest_opt_len");
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
|
@ -2101,8 +2101,7 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, bool is_init, bool match_
|
||||||
{
|
{
|
||||||
auto tt1 = t1->AsTypeType();
|
auto tt1 = t1->AsTypeType();
|
||||||
auto tt2 = t2->AsTypeType();
|
auto tt2 = t2->AsTypeType();
|
||||||
result =
|
result = same_type(tt1->GetType(), tt1->GetType(), is_init, match_record_field_names);
|
||||||
same_type(tt1->GetType(), tt1->GetType(), is_init, match_record_field_names);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -536,8 +536,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void)
|
||||||
benc_raw_type = detail::BENC_TYPE_DIR;
|
benc_raw_type = detail::BENC_TYPE_DIR;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
VIOLATION_IF(benc_stack.back() == 'd' &&
|
VIOLATION_IF(benc_stack.back() == 'd' && ! (benc_count.back() % 2),
|
||||||
! (benc_count.back() % 2),
|
|
||||||
"BitTorrentTracker: directory key is not a string "
|
"BitTorrentTracker: directory key is not a string "
|
||||||
"but a directory")
|
"but a directory")
|
||||||
++benc_raw_len;
|
++benc_raw_len;
|
||||||
|
@ -561,8 +560,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void)
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
||||||
default:
|
default:
|
||||||
VIOLATION_IF(benc_stack.back() == 'd' &&
|
VIOLATION_IF(benc_stack.back() == 'd' && ! (benc_count.back() % 2),
|
||||||
! (benc_count.back() % 2),
|
|
||||||
"BitTorrentTracker: directory key is not a string "
|
"BitTorrentTracker: directory key is not a string "
|
||||||
"but a list")
|
"but a list")
|
||||||
++benc_raw_len;
|
++benc_raw_len;
|
||||||
|
@ -573,11 +571,9 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
VIOLATION_IF(
|
VIOLATION_IF(! benc_stack.size(),
|
||||||
! benc_stack.size(),
|
|
||||||
"BitTorrentTracker: not a bencoded directory (first char: i)")
|
"BitTorrentTracker: not a bencoded directory (first char: i)")
|
||||||
VIOLATION_IF(
|
VIOLATION_IF(benc_stack.back() == 'd' && ! (benc_count.back() % 2),
|
||||||
benc_stack.back() == 'd' && ! (benc_count.back() % 2),
|
|
||||||
"BitTorrentTracker: directory key is not a string but an int")
|
"BitTorrentTracker: directory key is not a string but an int")
|
||||||
|
|
||||||
if ( benc_raw_type != detail::BENC_TYPE_NONE )
|
if ( benc_raw_type != detail::BENC_TYPE_NONE )
|
||||||
|
@ -587,8 +583,7 @@ int BitTorrentTracker_Analyzer::ResponseParseBenc(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
VIOLATION_IF(
|
VIOLATION_IF(! benc_stack.size(),
|
||||||
! benc_stack.size(),
|
|
||||||
"BitTorrentTracker: not a bencoded directory (first char: e)")
|
"BitTorrentTracker: not a bencoded directory (first char: e)")
|
||||||
VIOLATION_IF(benc_stack.back() == 'd' && benc_count.back() % 2,
|
VIOLATION_IF(benc_stack.back() == 'd' && benc_count.back() % 2,
|
||||||
"BitTorrentTracker: directory has an odd count of members")
|
"BitTorrentTracker: directory has an odd count of members")
|
||||||
|
|
|
@ -801,8 +801,8 @@ bool DNS_Interpreter::ParseRR_EDNS(detail::DNS_MsgInfo* msg, const u_char*& data
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
analyzer->EnqueueConnEvent(dns_EDNS_ecs, analyzer->ConnVal(),
|
analyzer->EnqueueConnEvent(dns_EDNS_ecs, analyzer->ConnVal(), msg->BuildHdrVal(),
|
||||||
msg->BuildHdrVal(), msg->BuildEDNS_ECS_Val(&opt));
|
msg->BuildEDNS_ECS_Val(&opt));
|
||||||
data += option_len;
|
data += option_len;
|
||||||
break;
|
break;
|
||||||
} // END EDNS ECS
|
} // END EDNS ECS
|
||||||
|
@ -860,8 +860,7 @@ bool DNS_Interpreter::ParseRR_EDNS(detail::DNS_MsgInfo* msg, const u_char*& data
|
||||||
int client_cookie_len = 8;
|
int client_cookie_len = 8;
|
||||||
int server_cookie_len = option_len - client_cookie_len;
|
int server_cookie_len = option_len - client_cookie_len;
|
||||||
|
|
||||||
cookie.client_cookie =
|
cookie.client_cookie = ExtractStream(data, client_cookie_len, client_cookie_len);
|
||||||
ExtractStream(data, client_cookie_len, client_cookie_len);
|
|
||||||
cookie.server_cookie = nullptr;
|
cookie.server_cookie = nullptr;
|
||||||
|
|
||||||
if ( server_cookie_len >= 8 )
|
if ( server_cookie_len >= 8 )
|
||||||
|
@ -870,8 +869,7 @@ bool DNS_Interpreter::ParseRR_EDNS(detail::DNS_MsgInfo* msg, const u_char*& data
|
||||||
ExtractStream(data, server_cookie_len, server_cookie_len);
|
ExtractStream(data, server_cookie_len, server_cookie_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
analyzer->EnqueueConnEvent(dns_EDNS_cookie, analyzer->ConnVal(),
|
analyzer->EnqueueConnEvent(dns_EDNS_cookie, analyzer->ConnVal(), msg->BuildHdrVal(),
|
||||||
msg->BuildHdrVal(),
|
|
||||||
msg->BuildEDNS_COOKIE_Val(&cookie));
|
msg->BuildEDNS_COOKIE_Val(&cookie));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -942,8 +942,7 @@ void HTTP_Analyzer::DeliverStream(int len, const u_char* data, bool is_orig)
|
||||||
request_ongoing = 1;
|
request_ongoing = 1;
|
||||||
unanswered_requests.push(request_method);
|
unanswered_requests.push(request_method);
|
||||||
HTTP_Request();
|
HTTP_Request();
|
||||||
InitHTTPMessage(content_line, request_message, is_orig, HTTP_BODY_MAYBE,
|
InitHTTPMessage(content_line, request_message, is_orig, HTTP_BODY_MAYBE, len);
|
||||||
len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -209,8 +209,7 @@ void TelnetAuthenticateOption::RecvSubOption(u_char* data, int len)
|
||||||
{
|
{
|
||||||
case HERE_IS_AUTHENTICATION:
|
case HERE_IS_AUTHENTICATION:
|
||||||
{
|
{
|
||||||
TelnetAuthenticateOption* peer =
|
TelnetAuthenticateOption* peer = (TelnetAuthenticateOption*)endp->FindPeerOption(code);
|
||||||
(TelnetAuthenticateOption*)endp->FindPeerOption(code);
|
|
||||||
|
|
||||||
if ( ! peer )
|
if ( ! peer )
|
||||||
{
|
{
|
||||||
|
|
|
@ -650,8 +650,7 @@ void Contents_RPC::DeliverStream(int len, const u_char* data, bool orig)
|
||||||
|
|
||||||
if ( ! dummy_p )
|
if ( ! dummy_p )
|
||||||
{
|
{
|
||||||
reporter->AnalyzerError(this,
|
reporter->AnalyzerError(this, "inconsistent RPC record marker extraction");
|
||||||
"inconsistent RPC record marker extraction");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,9 +691,8 @@ void Contents_RPC::DeliverStream(int len, const u_char* data, bool orig)
|
||||||
const u_char* dummy_p = msg_buf.GetBuf();
|
const u_char* dummy_p = msg_buf.GetBuf();
|
||||||
int dummy_len = (int)msg_buf.GetFill();
|
int dummy_len = (int)msg_buf.GetFill();
|
||||||
|
|
||||||
if ( ! interp->DeliverRPC(dummy_p, dummy_len,
|
if ( ! interp->DeliverRPC(dummy_p, dummy_len, (int)msg_buf.GetExpected(),
|
||||||
(int)msg_buf.GetExpected(), IsOrig(),
|
IsOrig(), start_time, last_time) )
|
||||||
start_time, last_time) )
|
|
||||||
Conn()->Weird("partial_RPC");
|
Conn()->Weird("partial_RPC");
|
||||||
|
|
||||||
state = WAIT_FOR_MESSAGE;
|
state = WAIT_FOR_MESSAGE;
|
||||||
|
|
|
@ -70,8 +70,7 @@ broker::backend_options to_backend_options(broker::backend backend, RecordVal* o
|
||||||
{
|
{
|
||||||
case broker::backend::sqlite:
|
case broker::backend::sqlite:
|
||||||
{
|
{
|
||||||
auto path =
|
auto path = options->GetFieldAs<RecordVal>(0)->GetFieldAs<StringVal>(0)->CheckString();
|
||||||
options->GetFieldAs<RecordVal>(0)->GetFieldAs<StringVal>(0)->CheckString();
|
|
||||||
return {{"path", path}};
|
return {{"path", path}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2354,8 +2354,7 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, Type* request_type,
|
||||||
auto t = make_intrusive<TableVal>(std::move(s));
|
auto t = make_intrusive<TableVal>(std::move(s));
|
||||||
for ( int j = 0; j < val->val.set_val.size; j++ )
|
for ( int j = 0; j < val->val.set_val.size; j++ )
|
||||||
{
|
{
|
||||||
Val* assignval =
|
Val* assignval = ValueToVal(i, val->val.set_val.vals[j], type.get(), have_error);
|
||||||
ValueToVal(i, val->val.set_val.vals[j], type.get(), have_error);
|
|
||||||
|
|
||||||
if ( have_error )
|
if ( have_error )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -2401,8 +2400,8 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, Type* request_type,
|
||||||
bro_int_t index = request_type->AsEnumType()->Lookup(module, var.c_str());
|
bro_int_t index = request_type->AsEnumType()->Lookup(module, var.c_str());
|
||||||
if ( index == -1 )
|
if ( index == -1 )
|
||||||
{
|
{
|
||||||
Warning(i, "Value '%s' for stream '%s' is not a valid enum.",
|
Warning(i, "Value '%s' for stream '%s' is not a valid enum.", enum_string.c_str(),
|
||||||
enum_string.c_str(), i->name.c_str());
|
i->name.c_str());
|
||||||
|
|
||||||
have_error = true;
|
have_error = true;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -278,8 +278,8 @@ int SQLite::AddParams(Value* val, int pos)
|
||||||
if ( ! val->val.string_val.length || val->val.string_val.length == 0 )
|
if ( ! val->val.string_val.length || val->val.string_val.length == 0 )
|
||||||
return sqlite3_bind_null(st, pos);
|
return sqlite3_bind_null(st, pos);
|
||||||
|
|
||||||
return sqlite3_bind_text(st, pos, val->val.string_val.data,
|
return sqlite3_bind_text(st, pos, val->val.string_val.data, val->val.string_val.length,
|
||||||
val->val.string_val.length, SQLITE_TRANSIENT);
|
SQLITE_TRANSIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
case TYPE_TABLE:
|
case TYPE_TABLE:
|
||||||
|
|
|
@ -651,8 +651,8 @@ Val* Value::ValueToVal(const std::string& source, const Value* val, bool& have_e
|
||||||
int intval = t->Lookup(id->ModuleName(), id->Name());
|
int intval = t->Lookup(id->ModuleName(), id->Name());
|
||||||
if ( intval < 0 )
|
if ( intval < 0 )
|
||||||
{
|
{
|
||||||
reporter->Warning("Enum value '%s' for source '%s' not found.",
|
reporter->Warning("Enum value '%s' for source '%s' not found.", enum_string.c_str(),
|
||||||
enum_string.c_str(), source.c_str());
|
source.c_str());
|
||||||
|
|
||||||
have_error = true;
|
have_error = true;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -348,8 +348,8 @@ Value* Ascii::ParseValue(const string& s, const string& name, TypeTag type, Type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GetThread()->Warning(GetThread()->Fmt("String '%s' contained no parseable pattern.",
|
GetThread()->Warning(
|
||||||
candidate.c_str()));
|
GetThread()->Fmt("String '%s' contained no parseable pattern.", candidate.c_str()));
|
||||||
goto parse_error;
|
goto parse_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,8 +152,7 @@ void JSON::BuildJSON(NullDoubleWriter& writer, Value* val, const std::string& na
|
||||||
if ( frac < 0 )
|
if ( frac < 0 )
|
||||||
frac += 1;
|
frac += 1;
|
||||||
|
|
||||||
snprintf(buffer2, sizeof(buffer2), "%s.%06.0fZ", buffer,
|
snprintf(buffer2, sizeof(buffer2), "%s.%06.0fZ", buffer, fabs(frac) * 1000000);
|
||||||
fabs(frac) * 1000000);
|
|
||||||
writer.String(buffer2, strlen(buffer2));
|
writer.String(buffer2, strlen(buffer2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,8 +82,7 @@ static void write_plugin_components(FILE* f, const plugin::Plugin* p)
|
||||||
{
|
{
|
||||||
case plugin::component::ANALYZER:
|
case plugin::component::ANALYZER:
|
||||||
{
|
{
|
||||||
const analyzer::Component* c =
|
const analyzer::Component* c = dynamic_cast<const analyzer::Component*>(component);
|
||||||
dynamic_cast<const analyzer::Component*>(component);
|
|
||||||
|
|
||||||
if ( c )
|
if ( c )
|
||||||
write_analyzer_component(f, c);
|
write_analyzer_component(f, c);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue