mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 21:48:21 +00:00
Merge remote-tracking branch 'origin/topic/bbannier/cppcoreguidelines-pro-type-cstyle-cast'
Some checks are pending
pre-commit / pre-commit (push) Waiting to run
Some checks are pending
pre-commit / pre-commit (push) Waiting to run
* origin/topic/bbannier/cppcoreguidelines-pro-type-cstyle-cast: Fixes for cppcoreguidelines-pro-type-cstyle-cast
This commit is contained in:
commit
df32e7d544
134 changed files with 669 additions and 612 deletions
|
@ -10,6 +10,7 @@ Checks: [-*,
|
|||
cppcoreguidelines-macro-usage,
|
||||
cppcoreguidelines-misleading-capture-default-by-value,
|
||||
cppcoreguidelines-virtual-class-destructor,
|
||||
cppcoreguidelines-pro-type-cstyle-cast,
|
||||
|
||||
# Skipping these temporarily because they are very noisy
|
||||
-bugprone-forward-declaration-namespace,
|
||||
|
@ -57,7 +58,6 @@ Checks: [-*,
|
|||
#cppcoreguidelines-init-variables,
|
||||
#cppcoreguidelines-prefer-member-initializer,
|
||||
#cppcoreguidelines-pro-type-member-init,
|
||||
#cppcoreguidelines-pro-type-cstyle-cast,
|
||||
#cppcoreguidelines-pro-type-static-cast-downcast,
|
||||
#cppcoreguidelines-special-member-functions,
|
||||
|
||||
|
|
4
CHANGES
4
CHANGES
|
@ -1,3 +1,7 @@
|
|||
8.1.0-dev.718 | 2025-10-15 13:46:49 -0700
|
||||
|
||||
* Fixes for cppcoreguidelines-pro-type-cstyle-cast (Benjamin Bannier, Corelight)
|
||||
|
||||
8.1.0-dev.716 | 2025-10-15 13:14:50 -0700
|
||||
|
||||
* Add linkcheck to docs generation workflow (Tim Wojtulewicz, Corelight)
|
||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
|||
8.1.0-dev.716
|
||||
8.1.0-dev.718
|
||||
|
|
|
@ -92,7 +92,7 @@ ipaddr32_t AnonymizeIPAddr_RandomMD5::anonymize(ipaddr32_t input) {
|
|||
uint8_t digest[16];
|
||||
ipaddr32_t output = 0;
|
||||
|
||||
util::detail::hmac_md5(sizeof(input), (u_char*)(&input), digest);
|
||||
util::detail::hmac_md5(sizeof(input), reinterpret_cast<u_char*>(&input), digest);
|
||||
|
||||
for ( int i = 0; i < 4; ++i )
|
||||
output = (output << 8) | digest[i];
|
||||
|
@ -117,7 +117,7 @@ ipaddr32_t AnonymizeIPAddr_PrefixMD5::anonymize(ipaddr32_t input) {
|
|||
prefix.prefix = htonl((input & ~(prefix_mask >> i)) | (1 << (31 - i)));
|
||||
|
||||
// HK(PAD(x_0 ... x_{i-1})).
|
||||
util::detail::hmac_md5(sizeof(prefix), (u_char*)&prefix, digest);
|
||||
util::detail::hmac_md5(sizeof(prefix), reinterpret_cast<u_char*>(&prefix), digest);
|
||||
|
||||
// f_{i-1} = LSB(HK(PAD(x_0 ... x_{i-1}))).
|
||||
ipaddr32_t bit_mask = (digest[0] & 1) << (31 - i);
|
||||
|
|
|
@ -221,7 +221,7 @@ String* decode_base64(const String* s, const String* a, Connection* conn) {
|
|||
char* rbuf = new char[rlen];
|
||||
|
||||
Base64Converter dec(conn, a ? a->CheckString() : "");
|
||||
dec.Decode(s->Len(), (const char*)s->Bytes(), &rlen, &rbuf);
|
||||
dec.Decode(s->Len(), reinterpret_cast<const char*>(s->Bytes()), &rlen, &rbuf);
|
||||
|
||||
if ( dec.Errored() ) {
|
||||
delete[] rbuf;
|
||||
|
@ -236,7 +236,7 @@ String* decode_base64(const String* s, const String* a, Connection* conn) {
|
|||
rlen += rlen2;
|
||||
|
||||
rbuf[rlen] = '\0';
|
||||
return new String(true, (u_char*)rbuf, rlen);
|
||||
return new String(true, reinterpret_cast<u_char*>(rbuf), rlen);
|
||||
}
|
||||
|
||||
String* encode_base64(const String* s, const String* a, Connection* conn) {
|
||||
|
@ -250,7 +250,7 @@ String* encode_base64(const String* s, const String* a, Connection* conn) {
|
|||
Base64Converter enc(conn, a ? a->CheckString() : "");
|
||||
enc.Encode(s->Len(), (const unsigned char*)s->Bytes(), &outlen, &outbuf);
|
||||
|
||||
return new String(true, (u_char*)outbuf, outlen);
|
||||
return new String(true, reinterpret_cast<u_char*>(outbuf), outlen);
|
||||
}
|
||||
|
||||
} // namespace zeek::detail
|
||||
|
|
|
@ -386,7 +386,8 @@ bool CompositeHash::RecoverOneVal(const HashKey& hk, Type* t, ValPtr* pval, bool
|
|||
hk.EnsureReadSpace(n);
|
||||
}
|
||||
|
||||
*pval = make_intrusive<StringVal>(new String((const byte_vec)hk.KeyAtRead(), n, true));
|
||||
*pval =
|
||||
make_intrusive<StringVal>(new String(reinterpret_cast<const unsigned char*>(hk.KeyAtRead()), n, true));
|
||||
hk.SkipRead("string", n);
|
||||
} break;
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class DFA_Machine;
|
|||
// Transitions to the uncomputed state indicate that we haven't yet
|
||||
// computed the state to go to.
|
||||
#define DFA_UNCOMPUTED_STATE (-2)
|
||||
#define DFA_UNCOMPUTED_STATE_PTR ((DFA_State*)DFA_UNCOMPUTED_STATE)
|
||||
#define DFA_UNCOMPUTED_STATE_PTR (reinterpret_cast<DFA_State*>(DFA_UNCOMPUTED_STATE))
|
||||
|
||||
class DFA_State : public Obj {
|
||||
public:
|
||||
|
|
|
@ -130,10 +130,11 @@ void DNS_Mapping::Init(struct hostent* h) {
|
|||
|
||||
if ( h->h_addr_list ) {
|
||||
for ( int i = 0; h->h_addr_list[i] != nullptr; ++i ) {
|
||||
auto* addr = reinterpret_cast<uint32_t*>(h->h_addr_list[i]);
|
||||
if ( h->h_addrtype == AF_INET )
|
||||
addrs.emplace_back(IPv4, (uint32_t*)h->h_addr_list[i], IPAddr::Network);
|
||||
addrs.emplace_back(IPv4, addr, IPAddr::Network);
|
||||
else if ( h->h_addrtype == AF_INET6 )
|
||||
addrs.emplace_back(IPv6, (uint32_t*)h->h_addr_list[i], IPAddr::Network);
|
||||
addrs.emplace_back(IPv6, addr, IPAddr::Network);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ static void addrinfo_cb(void* arg, int status, int timeouts, struct ares_addrinf
|
|||
addrs.push_back(&addr->sin_addr);
|
||||
}
|
||||
else if ( entry->ai_family == AF_INET6 ) {
|
||||
struct sockaddr_in6* addr = (struct sockaddr_in6*)(entry->ai_addr);
|
||||
struct sockaddr_in6* addr = reinterpret_cast<sockaddr_in6*>(entry->ai_addr);
|
||||
addrs6.push_back(&addr->sin6_addr);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -730,7 +730,7 @@ int dbg_handle_debug_input() {
|
|||
|
||||
// readline uses malloc, and we want to be consistent
|
||||
// with it.
|
||||
input_line = (char*)util::safe_malloc(1024);
|
||||
input_line = reinterpret_cast<char*>(util::safe_malloc(1024));
|
||||
input_line[1023] = 0;
|
||||
// ### Maybe it's not always stdin.
|
||||
input_line = fgets(input_line, 1023, stdin);
|
||||
|
|
16
src/Desc.cc
16
src/Desc.cc
|
@ -24,7 +24,7 @@ ODesc::ODesc(DescType t, File* arg_f) {
|
|||
if ( f == nullptr ) {
|
||||
size = DEFAULT_SIZE;
|
||||
base = util::safe_malloc(size);
|
||||
((char*)base)[0] = '\0';
|
||||
(reinterpret_cast<char*>(base))[0] = '\0';
|
||||
offset = 0;
|
||||
}
|
||||
else {
|
||||
|
@ -76,7 +76,7 @@ void ODesc::PopIndentNoNL() {
|
|||
void ODesc::Add(const char* s, int do_indent) {
|
||||
size_t n = strlen(s);
|
||||
|
||||
if ( do_indent && IsReadable() && offset > 0 && ((const char*)base)[offset - 1] == '\n' )
|
||||
if ( do_indent && IsReadable() && offset > 0 && (reinterpret_cast<const char*>(base))[offset - 1] == '\n' )
|
||||
Indent();
|
||||
|
||||
if ( IsBinary() )
|
||||
|
@ -241,8 +241,8 @@ void ODesc::AddBytes(const void* bytes, size_t n) {
|
|||
return;
|
||||
}
|
||||
|
||||
const char* s = (const char*)bytes;
|
||||
const char* e = (const char*)bytes + n;
|
||||
const char* s = reinterpret_cast<const char*>(bytes);
|
||||
const char* e = reinterpret_cast<const char*>(bytes) + n;
|
||||
|
||||
while ( s < e ) {
|
||||
auto [esc_start, esc_len] = FirstEscapeLoc(s, e - s);
|
||||
|
@ -278,7 +278,7 @@ void ODesc::AddBytesRaw(const void* bytes, size_t n) {
|
|||
if ( f ) {
|
||||
static bool write_failed = false;
|
||||
|
||||
if ( ! f->Write((const char*)bytes, n) ) {
|
||||
if ( ! f->Write(reinterpret_cast<const char*>(bytes), n) ) {
|
||||
if ( ! write_failed )
|
||||
// Most likely it's a "disk full" so report
|
||||
// subsequent failures only once.
|
||||
|
@ -297,10 +297,10 @@ void ODesc::AddBytesRaw(const void* bytes, size_t n) {
|
|||
// The following casting contortions are necessary because
|
||||
// simply using &base[offset] generates complaints about
|
||||
// using a void* for pointer arithmetic.
|
||||
memcpy((void*)&((char*)base)[offset], bytes, n);
|
||||
memcpy((void*)&(reinterpret_cast<char*>(base))[offset], bytes, n);
|
||||
offset += n;
|
||||
|
||||
((char*)base)[offset] = '\0'; // ensure that always NUL-term.
|
||||
(reinterpret_cast<char*>(base))[offset] = '\0'; // ensure that always NUL-term.
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -324,7 +324,7 @@ void ODesc::Clear() {
|
|||
free(base);
|
||||
size = DEFAULT_SIZE;
|
||||
base = util::safe_malloc(size);
|
||||
((char*)base)[0] = '\0';
|
||||
(reinterpret_cast<char*>(base))[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,9 +130,9 @@ public:
|
|||
void AddRaw(const std::string& s) { AddBytesRaw(s.data(), s.size()); }
|
||||
|
||||
// Returns the description as a string.
|
||||
const char* Description() const { return (const char*)base; }
|
||||
const char* Description() const { return reinterpret_cast<const char*>(base); }
|
||||
|
||||
const u_char* Bytes() const { return (const u_char*)base; }
|
||||
const u_char* Bytes() const { return reinterpret_cast<const u_char*>(base); }
|
||||
byte_vec TakeBytes() {
|
||||
const void* t = base;
|
||||
base = nullptr;
|
||||
|
|
14
src/Dict.cc
14
src/Dict.cc
|
@ -120,7 +120,7 @@ TEST_CASE("dict iteration") {
|
|||
|
||||
for ( const auto& entry : dict ) {
|
||||
auto* v = static_cast<uint32_t*>(entry.value);
|
||||
uint64_t k = *(uint32_t*)entry.GetKey();
|
||||
uint64_t k = *reinterpret_cast<const uint32_t*>(entry.GetKey());
|
||||
|
||||
switch ( count ) {
|
||||
case 0:
|
||||
|
@ -172,7 +172,7 @@ TEST_CASE("dict robust iteration") {
|
|||
|
||||
for ( ; it != dict.end_robust(); ++it ) {
|
||||
auto* v = it->value;
|
||||
uint64_t k = *(uint32_t*)it->GetKey();
|
||||
uint64_t k = *reinterpret_cast<const uint32_t*>(it->GetKey());
|
||||
|
||||
switch ( count ) {
|
||||
case 0:
|
||||
|
@ -205,7 +205,7 @@ TEST_CASE("dict robust iteration") {
|
|||
|
||||
for ( ; it != dict.end_robust(); ++it ) {
|
||||
auto* v = it->value;
|
||||
uint64_t k = *(uint32_t*)it->GetKey();
|
||||
uint64_t k = *reinterpret_cast<const uint32_t*>(it->GetKey());
|
||||
|
||||
switch ( count ) {
|
||||
case 0:
|
||||
|
@ -265,7 +265,7 @@ TEST_CASE("dict ordered iteration") {
|
|||
|
||||
for ( const auto& entry : dict ) {
|
||||
auto* v = static_cast<uint32_t*>(entry.value);
|
||||
uint32_t k = *(uint32_t*)entry.GetKey();
|
||||
uint32_t k = *reinterpret_cast<const uint32_t*>(entry.GetKey());
|
||||
|
||||
// The keys should be returned in the same order we inserted
|
||||
// them, which is 5, 25, 45.
|
||||
|
@ -284,7 +284,7 @@ TEST_CASE("dict ordered iteration") {
|
|||
|
||||
for ( const auto& entry : dict ) {
|
||||
auto* v = static_cast<uint32_t*>(entry.value);
|
||||
uint32_t k = *(uint32_t*)entry.GetKey();
|
||||
uint32_t k = *reinterpret_cast<const uint32_t*>(entry.GetKey());
|
||||
|
||||
// The keys should be returned in the same order we inserted
|
||||
// them, which is 5, 25, 45, 35.
|
||||
|
@ -305,7 +305,7 @@ TEST_CASE("dict ordered iteration") {
|
|||
|
||||
for ( const auto& entry : dict ) {
|
||||
auto* v = static_cast<uint32_t*>(entry.value);
|
||||
uint32_t k = *(uint32_t*)entry.GetKey();
|
||||
uint32_t k = *reinterpret_cast<const uint32_t*>(entry.GetKey());
|
||||
|
||||
// The keys should be returned in the same order we inserted
|
||||
// them, which is 5, 45, 35.
|
||||
|
@ -367,7 +367,7 @@ TEST_CASE("dict robust iteration replacement") {
|
|||
|
||||
// This shouldn't crash with AddressSanitizer
|
||||
for ( ; it != dict.end_robust(); ++it ) {
|
||||
uint64_t k = *(uint32_t*)it->GetKey();
|
||||
uint64_t k = *reinterpret_cast<const uint32_t*>(it->GetKey());
|
||||
auto* v = it->value;
|
||||
CHECK(v->v == 50);
|
||||
}
|
||||
|
|
14
src/Dict.h
14
src/Dict.h
|
@ -114,7 +114,7 @@ public:
|
|||
if ( key_size <= 8 ) {
|
||||
memcpy(key_here, arg_key, key_size);
|
||||
if ( ! copy_key )
|
||||
delete[] (char*)arg_key; // own the arg_key, now don't need it.
|
||||
delete[] reinterpret_cast<char*>(arg_key); // own the arg_key, now don't need it.
|
||||
}
|
||||
else {
|
||||
if ( copy_key ) {
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
memcpy(key, arg_key, key_size);
|
||||
}
|
||||
else {
|
||||
key = (char*)arg_key;
|
||||
key = reinterpret_cast<char*>(arg_key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ public:
|
|||
v = table[position].value;
|
||||
table[position].value = val;
|
||||
if ( ! copy_key )
|
||||
delete[] (char*)key;
|
||||
delete[] reinterpret_cast<char*>(key);
|
||||
|
||||
if ( iterators && ! iterators->empty() )
|
||||
// need to set new v for iterators too.
|
||||
|
@ -747,7 +747,7 @@ public:
|
|||
|
||||
T* NthEntry(int n, const char*& key) const {
|
||||
int key_len;
|
||||
return NthEntry(n, (const void*&)key, key_len);
|
||||
return NthEntry(n, key, key_len);
|
||||
}
|
||||
|
||||
void SetDeleteFunc(dict_delete_func f) { delete_func = f; }
|
||||
|
@ -927,7 +927,7 @@ public:
|
|||
for ( int idx = 0; idx < Capacity(); idx++ )
|
||||
if ( ! table[idx].Empty() ) {
|
||||
int key_size = table[idx].key_size;
|
||||
f.write((const char*)&key_size, sizeof(int));
|
||||
f.write(reinterpret_cast<const char*>(&key_size), sizeof(int));
|
||||
f.write(table[idx].GetKey(), table[idx].key_size);
|
||||
}
|
||||
}
|
||||
|
@ -1129,7 +1129,7 @@ private:
|
|||
int LinearLookupIndex(const void* key, int key_size, detail::hash_t hash) const {
|
||||
auto current_cap = Capacity();
|
||||
for ( int i = 0; i < current_cap; i++ )
|
||||
if ( ! table[i].Empty() && table[i].Equal((const char*)key, key_size, hash) )
|
||||
if ( ! table[i].Empty() && table[i].Equal(reinterpret_cast<const char*>(key), key_size, hash) )
|
||||
return i;
|
||||
return -1;
|
||||
}
|
||||
|
@ -1189,7 +1189,7 @@ private:
|
|||
ASSERT(begin >= 0 && begin < Buckets());
|
||||
int i = begin;
|
||||
for ( ; i < end && ! table[i].Empty() && BucketByPosition(i) <= begin; i++ )
|
||||
if ( BucketByPosition(i) == begin && table[i].Equal((char*)key, key_size, hash) )
|
||||
if ( BucketByPosition(i) == begin && table[i].Equal(reinterpret_cast<const char*>(key), key_size, hash) )
|
||||
return i;
|
||||
|
||||
// no such cluster, or not found in the cluster.
|
||||
|
|
|
@ -72,7 +72,7 @@ bool Discarder::NextPacket(const std::shared_ptr<IP_Hdr>& ip, int len, int caple
|
|||
|
||||
if ( is_tcp ) {
|
||||
if ( check_tcp ) {
|
||||
const struct tcphdr* tp = (const struct tcphdr*)data;
|
||||
const struct tcphdr* tp = reinterpret_cast<const tcphdr*>(data);
|
||||
int th_len = tp->th_off * 4;
|
||||
|
||||
zeek::Args args{
|
||||
|
@ -92,7 +92,7 @@ bool Discarder::NextPacket(const std::shared_ptr<IP_Hdr>& ip, int len, int caple
|
|||
|
||||
else if ( is_udp ) {
|
||||
if ( check_udp ) {
|
||||
const struct udphdr* up = (const struct udphdr*)data;
|
||||
const struct udphdr* up = reinterpret_cast<const udphdr*>(data);
|
||||
int uh_len = sizeof(struct udphdr);
|
||||
|
||||
zeek::Args args{
|
||||
|
@ -112,7 +112,7 @@ bool Discarder::NextPacket(const std::shared_ptr<IP_Hdr>& ip, int len, int caple
|
|||
|
||||
else {
|
||||
if ( check_icmp ) {
|
||||
const struct icmp* ih = (const struct icmp*)data;
|
||||
const struct icmp* ih = reinterpret_cast<const icmp*>(data);
|
||||
|
||||
zeek::Args args{ip->ToPktHdrVal()};
|
||||
|
||||
|
|
46
src/Expr.cc
46
src/Expr.cc
|
@ -133,87 +133,87 @@ Expr::~Expr() { delete opt_info; }
|
|||
|
||||
const ListExpr* Expr::AsListExpr() const {
|
||||
CHECK_TAG(tag, EXPR_LIST, "Expr::AsListExpr", expr_name)
|
||||
return (const ListExpr*)this;
|
||||
return static_cast<const ListExpr*>(this);
|
||||
}
|
||||
|
||||
ListExpr* Expr::AsListExpr() {
|
||||
CHECK_TAG(tag, EXPR_LIST, "Expr::AsListExpr", expr_name)
|
||||
return (ListExpr*)this;
|
||||
return static_cast<ListExpr*>(this);
|
||||
}
|
||||
|
||||
ListExprPtr Expr::AsListExprPtr() {
|
||||
CHECK_TAG(tag, EXPR_LIST, "Expr::AsListExpr", expr_name)
|
||||
return {NewRef{}, (ListExpr*)this};
|
||||
return {NewRef{}, static_cast<ListExpr*>(this)};
|
||||
}
|
||||
|
||||
const NameExpr* Expr::AsNameExpr() const {
|
||||
CHECK_TAG(tag, EXPR_NAME, "Expr::AsNameExpr", expr_name)
|
||||
return (const NameExpr*)this;
|
||||
return static_cast<const NameExpr*>(this);
|
||||
}
|
||||
|
||||
NameExpr* Expr::AsNameExpr() {
|
||||
CHECK_TAG(tag, EXPR_NAME, "Expr::AsNameExpr", expr_name)
|
||||
return (NameExpr*)this;
|
||||
return static_cast<NameExpr*>(this);
|
||||
}
|
||||
|
||||
NameExprPtr Expr::AsNameExprPtr() {
|
||||
CHECK_TAG(tag, EXPR_NAME, "Expr::AsNameExpr", expr_name)
|
||||
return {NewRef{}, (NameExpr*)this};
|
||||
return {NewRef{}, static_cast<NameExpr*>(this)};
|
||||
}
|
||||
|
||||
const ConstExpr* Expr::AsConstExpr() const {
|
||||
CHECK_TAG(tag, EXPR_CONST, "Expr::AsConstExpr", expr_name)
|
||||
return (const ConstExpr*)this;
|
||||
return static_cast<const ConstExpr*>(this);
|
||||
}
|
||||
|
||||
ConstExprPtr Expr::AsConstExprPtr() {
|
||||
CHECK_TAG(tag, EXPR_CONST, "Expr::AsConstExpr", expr_name)
|
||||
return {NewRef{}, (ConstExpr*)this};
|
||||
return {NewRef{}, static_cast<ConstExpr*>(this)};
|
||||
}
|
||||
|
||||
const CallExpr* Expr::AsCallExpr() const {
|
||||
CHECK_TAG(tag, EXPR_CALL, "Expr::AsCallExpr", expr_name)
|
||||
return (const CallExpr*)this;
|
||||
return static_cast<const CallExpr*>(this);
|
||||
}
|
||||
|
||||
const AssignExpr* Expr::AsAssignExpr() const {
|
||||
CHECK_TAG(tag, EXPR_ASSIGN, "Expr::AsAssignExpr", expr_name)
|
||||
return (const AssignExpr*)this;
|
||||
return static_cast<const AssignExpr*>(this);
|
||||
}
|
||||
|
||||
AssignExpr* Expr::AsAssignExpr() {
|
||||
CHECK_TAG(tag, EXPR_ASSIGN, "Expr::AsAssignExpr", expr_name)
|
||||
return (AssignExpr*)this;
|
||||
return static_cast<AssignExpr*>(this);
|
||||
}
|
||||
|
||||
const IndexExpr* Expr::AsIndexExpr() const {
|
||||
CHECK_TAG(tag, EXPR_INDEX, "Expr::AsIndexExpr", expr_name)
|
||||
return (const IndexExpr*)this;
|
||||
return static_cast<const IndexExpr*>(this);
|
||||
}
|
||||
|
||||
IndexExpr* Expr::AsIndexExpr() {
|
||||
CHECK_TAG(tag, EXPR_INDEX, "Expr::AsIndexExpr", expr_name)
|
||||
return (IndexExpr*)this;
|
||||
return static_cast<IndexExpr*>(this);
|
||||
}
|
||||
|
||||
const EventExpr* Expr::AsEventExpr() const {
|
||||
CHECK_TAG(tag, EXPR_EVENT, "Expr::AsEventExpr", expr_name)
|
||||
return (const EventExpr*)this;
|
||||
return static_cast<const EventExpr*>(this);
|
||||
}
|
||||
|
||||
EventExprPtr Expr::AsEventExprPtr() {
|
||||
CHECK_TAG(tag, EXPR_EVENT, "Expr::AsEventExpr", expr_name)
|
||||
return {NewRef{}, (EventExpr*)this};
|
||||
return {NewRef{}, static_cast<EventExpr*>(this)};
|
||||
}
|
||||
|
||||
const RefExpr* Expr::AsRefExpr() const {
|
||||
CHECK_TAG(tag, EXPR_REF, "Expr::AsRefExpr", expr_name)
|
||||
return (const RefExpr*)this;
|
||||
return static_cast<const RefExpr*>(this);
|
||||
}
|
||||
|
||||
RefExprPtr Expr::AsRefExprPtr() {
|
||||
CHECK_TAG(tag, EXPR_REF, "Expr::AsRefExpr", expr_name)
|
||||
return {NewRef{}, (RefExpr*)this};
|
||||
return {NewRef{}, static_cast<RefExpr*>(this)};
|
||||
}
|
||||
|
||||
bool Expr::CanAdd() const { return false; }
|
||||
|
@ -2462,7 +2462,7 @@ TypePtr AssignExpr::InitType() const {
|
|||
bool AssignExpr::IsRecordElement(TypeDecl* td) const {
|
||||
if ( op1->Tag() == EXPR_NAME ) {
|
||||
if ( td ) {
|
||||
const NameExpr* n = (const NameExpr*)op1.get();
|
||||
const NameExpr* n = static_cast<const NameExpr*>(op1.get());
|
||||
td->type = op2->GetType();
|
||||
td->id = util::copy_string(n->Id()->Name());
|
||||
}
|
||||
|
@ -2940,7 +2940,7 @@ RecordConstructorExpr::RecordConstructorExpr(ListExprPtr constructor_list)
|
|||
continue;
|
||||
}
|
||||
|
||||
FieldAssignExpr* field = (FieldAssignExpr*)e;
|
||||
FieldAssignExpr* field = static_cast<FieldAssignExpr*>(e);
|
||||
const auto& field_type = field->GetType();
|
||||
char* field_name = util::copy_string(field->FieldName());
|
||||
record_types->push_back(new TypeDecl(field_name, field_type));
|
||||
|
@ -4099,14 +4099,14 @@ CallExpr::CallExpr(ExprPtr arg_func, ListExprPtr arg_args, bool in_hook, bool _i
|
|||
// run-time errors when we apply this analysis during
|
||||
// parsing. Really we should instead do it after we've
|
||||
// parsed the entire set of scripts.
|
||||
util::streq(((NameExpr*)func.get())->Id()->Name(), "fmt") &&
|
||||
util::streq((static_cast<NameExpr*>(func.get()))->Id()->Name(), "fmt") &&
|
||||
// The following is needed because fmt might not yet
|
||||
// be bound as a name.
|
||||
did_builtin_init ) {
|
||||
func_val = func->Eval(nullptr);
|
||||
if ( func_val ) {
|
||||
zeek::Func* f = func_val->AsFunc();
|
||||
if ( f->GetKind() == Func::BUILTIN_FUNC && ! check_built_in_call((BuiltinFunc*)f, this) )
|
||||
if ( f->GetKind() == Func::BUILTIN_FUNC && ! check_built_in_call(static_cast<BuiltinFunc*>(f), this) )
|
||||
SetError();
|
||||
}
|
||||
}
|
||||
|
@ -4561,7 +4561,7 @@ ListExpr::~ListExpr() {
|
|||
|
||||
void ListExpr::Append(ExprPtr e) {
|
||||
exprs.push_back(e.release());
|
||||
((TypeList*)type.get())->Append(exprs.back()->GetType());
|
||||
(static_cast<TypeList*>(type.get()))->Append(exprs.back()->GetType());
|
||||
}
|
||||
|
||||
bool ListExpr::IsPure() const {
|
||||
|
@ -4710,7 +4710,7 @@ RecordAssignExpr::RecordAssignExpr(const ExprPtr& record, const ExprPtr& init_li
|
|||
}
|
||||
|
||||
else if ( init->Tag() == EXPR_FIELD_ASSIGN ) {
|
||||
FieldAssignExpr* rf = (FieldAssignExpr*)init;
|
||||
FieldAssignExpr* rf = static_cast<FieldAssignExpr*>(init);
|
||||
rf->Ref();
|
||||
|
||||
const char* field_name = ""; // rf->FieldName();
|
||||
|
|
|
@ -1681,7 +1681,7 @@ extern const char* assign_to_index(ValPtr v1, ValPtr v2, ValPtr v3, bool& iterat
|
|||
inline Val* Expr::ExprVal() const {
|
||||
if ( ! IsConst() )
|
||||
BadTag("ExprVal::Val", expr_name(tag), expr_name(EXPR_CONST));
|
||||
return ((ConstExpr*)this)->Value();
|
||||
return (static_cast<const ConstExpr*>(this))->Value();
|
||||
}
|
||||
|
||||
// Decides whether to return an AssignExpr or a RecordAssignExpr.
|
||||
|
|
15
src/Frag.cc
15
src/Frag.cc
|
@ -67,7 +67,8 @@ void FragReassembler::AddFragment(double t, const std::shared_ptr<IP_Hdr>& ip, c
|
|||
const struct ip* ip4 = ip->IP4_Hdr();
|
||||
|
||||
if ( ip4 ) {
|
||||
if ( ip4->ip_p != ((const struct ip*)proto_hdr)->ip_p || ip4->ip_hl != ((const struct ip*)proto_hdr)->ip_hl )
|
||||
if ( ip4->ip_p != (reinterpret_cast<const struct ip*>(proto_hdr))->ip_p ||
|
||||
ip4->ip_hl != (reinterpret_cast<const struct ip*>(proto_hdr))->ip_hl )
|
||||
// || ip4->ip_tos != proto_hdr->ip_tos
|
||||
// don't check TOS, there's at least one stack that actually
|
||||
// uses different values, and it's hard to see an associated
|
||||
|
@ -139,15 +140,15 @@ void FragReassembler::AddFragment(double t, const std::shared_ptr<IP_Hdr>& ip, c
|
|||
}
|
||||
|
||||
void FragReassembler::Weird(const char* name) const {
|
||||
unsigned int version = ((const ip*)proto_hdr)->ip_v;
|
||||
unsigned int version = (reinterpret_cast<const ip*>(proto_hdr))->ip_v;
|
||||
|
||||
if ( version == 4 ) {
|
||||
IP_Hdr hdr((const ip*)proto_hdr, false);
|
||||
IP_Hdr hdr(reinterpret_cast<const ip*>(proto_hdr), false);
|
||||
s->Weird(name, &hdr);
|
||||
}
|
||||
|
||||
else if ( version == 6 ) {
|
||||
IP_Hdr hdr((const ip6_hdr*)proto_hdr, false, proto_hdr_len);
|
||||
IP_Hdr hdr(reinterpret_cast<const ip6_hdr*>(proto_hdr), false, proto_hdr_len);
|
||||
s->Weird(name, &hdr);
|
||||
}
|
||||
|
||||
|
@ -256,17 +257,17 @@ void FragReassembler::BlockInserted(DataBlockMap::const_iterator /* it */) {
|
|||
|
||||
reassembled_pkt.reset();
|
||||
|
||||
unsigned int version = ((const struct ip*)pkt_start)->ip_v;
|
||||
unsigned int version = (reinterpret_cast<const ip*>(pkt_start))->ip_v;
|
||||
|
||||
if ( version == 4 ) {
|
||||
struct ip* reassem4 = (struct ip*)pkt_start;
|
||||
struct ip* reassem4 = reinterpret_cast<ip*>(pkt_start);
|
||||
reassem4->ip_len = htons(frag_size + proto_hdr_len);
|
||||
reassembled_pkt = std::make_shared<IP_Hdr>(reassem4, true, true);
|
||||
DeleteTimer();
|
||||
}
|
||||
|
||||
else if ( version == 6 ) {
|
||||
struct ip6_hdr* reassem6 = (struct ip6_hdr*)pkt_start;
|
||||
struct ip6_hdr* reassem6 = reinterpret_cast<ip6_hdr*>(pkt_start);
|
||||
reassem6->ip6_plen = htons(frag_size + proto_hdr_len - 40);
|
||||
const IPv6_Hdr_Chain* chain = new IPv6_Hdr_Chain(reassem6, next_proto, n);
|
||||
reassembled_pkt = std::make_shared<IP_Hdr>(reassem6, true, n, chain, true);
|
||||
|
|
16
src/Hash.cc
16
src/Hash.cc
|
@ -40,13 +40,13 @@ void KeyedHash::InitializeSeeds(const std::array<uint32_t, SEED_INIT_SIZE>& seed
|
|||
|
||||
// leaving this at being generated by md5, allowing user scripts that use hmac_md5 functionality
|
||||
// to get the same hash values as before. For now.
|
||||
internal_md5((const u_char*)seed_data.data(), sizeof(seed_data) - 16,
|
||||
internal_md5(reinterpret_cast<const u_char*>(seed_data.data()), sizeof(seed_data) - 16,
|
||||
shared_hmac_md5_key); // The last 128 bits of buf are for siphash
|
||||
// yes, we use the same buffer twice to initialize two different keys. This should not really be
|
||||
// a security problem of any kind: hmac-md5 is not really used anymore - and even if it was, the
|
||||
// hashes should not reveal any information about their initialization vector.
|
||||
static_assert(sizeof(shared_highwayhash_key) == ZEEK_SHA256_DIGEST_LENGTH);
|
||||
calculate_digest(Hash_SHA256, (const u_char*)seed_data.data(), sizeof(seed_data) - 16,
|
||||
calculate_digest(Hash_SHA256, reinterpret_cast<const u_char*>(seed_data.data()), sizeof(seed_data) - 16,
|
||||
reinterpret_cast<unsigned char*>(shared_highwayhash_key));
|
||||
memcpy(shared_siphash_key, reinterpret_cast<const char*>(seed_data.data()) + 64, 16);
|
||||
|
||||
|
@ -107,7 +107,7 @@ HashKey::HashKey(uint32_t u) { Set(u); }
|
|||
|
||||
HashKey::HashKey(const uint32_t u[], size_t n) {
|
||||
size = write_size = n * sizeof(u[0]);
|
||||
key = (char*)u;
|
||||
key = const_cast<char*>(reinterpret_cast<const char*>(u));
|
||||
}
|
||||
|
||||
HashKey::HashKey(double d) { Set(d); }
|
||||
|
@ -116,31 +116,31 @@ HashKey::HashKey(const void* p) { Set(p); }
|
|||
|
||||
HashKey::HashKey(const char* s) {
|
||||
size = write_size = strlen(s); // note - skip final \0
|
||||
key = (char*)s;
|
||||
key = const_cast<char*>(reinterpret_cast<const char*>(s));
|
||||
}
|
||||
|
||||
HashKey::HashKey(const String* s) {
|
||||
size = write_size = s->Len();
|
||||
key = (char*)s->Bytes();
|
||||
key = reinterpret_cast<char*>(s->Bytes());
|
||||
}
|
||||
|
||||
HashKey::HashKey(const void* bytes, size_t arg_size) {
|
||||
size = write_size = arg_size;
|
||||
key = CopyKey((char*)bytes, size);
|
||||
key = CopyKey(reinterpret_cast<const char*>(bytes), size);
|
||||
is_our_dynamic = true;
|
||||
}
|
||||
|
||||
HashKey::HashKey(const void* arg_key, size_t arg_size, hash_t arg_hash) {
|
||||
size = write_size = arg_size;
|
||||
hash = arg_hash;
|
||||
key = CopyKey((char*)arg_key, size);
|
||||
key = CopyKey(reinterpret_cast<const char*>(arg_key), size);
|
||||
is_our_dynamic = true;
|
||||
}
|
||||
|
||||
HashKey::HashKey(const void* arg_key, size_t arg_size, hash_t arg_hash, bool /* dont_copy */) {
|
||||
size = write_size = arg_size;
|
||||
hash = arg_hash;
|
||||
key = (char*)arg_key;
|
||||
key = const_cast<char*>(reinterpret_cast<const char*>(arg_key));
|
||||
}
|
||||
|
||||
HashKey::HashKey(const HashKey& other) : HashKey(other.key, other.size, other.hash) {}
|
||||
|
|
111
src/IP.cc
111
src/IP.cc
|
@ -28,7 +28,7 @@ static VectorValPtr BuildOptionsVal(const u_char* data, int len) {
|
|||
|
||||
while ( len > 0 && static_cast<size_t>(len) >= sizeof(struct ip6_opt) ) {
|
||||
static auto ip6_option_type = id::find_type<RecordType>("ip6_option");
|
||||
const struct ip6_opt* opt = (const struct ip6_opt*)data;
|
||||
const struct ip6_opt* opt = reinterpret_cast<const ip6_opt*>(data);
|
||||
auto rv = make_intrusive<RecordVal>(ip6_option_type);
|
||||
rv->Assign(0, opt->ip6o_type);
|
||||
|
||||
|
@ -65,7 +65,7 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
case IPPROTO_IPV6: {
|
||||
static auto ip6_hdr_type = id::find_type<RecordType>("ip6_hdr");
|
||||
rv = make_intrusive<RecordVal>(ip6_hdr_type);
|
||||
const struct ip6_hdr* ip6 = (const struct ip6_hdr*)data;
|
||||
const struct ip6_hdr* ip6 = reinterpret_cast<const ip6_hdr*>(data);
|
||||
rv->Assign(0, static_cast<uint32_t>(ntohl(ip6->ip6_flow) & 0x0ff00000) >> 20);
|
||||
rv->Assign(1, static_cast<uint32_t>(ntohl(ip6->ip6_flow) & 0x000fffff));
|
||||
rv->Assign(2, ntohs(ip6->ip6_plen));
|
||||
|
@ -85,7 +85,7 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
|
||||
static auto ip6_hopopts_type = id::find_type<RecordType>("ip6_hopopts");
|
||||
rv = make_intrusive<RecordVal>(ip6_hopopts_type);
|
||||
const struct ip6_hbh* hbh = (const struct ip6_hbh*)data;
|
||||
const struct ip6_hbh* hbh = reinterpret_cast<const ip6_hbh*>(data);
|
||||
rv->Assign(0, hbh->ip6h_nxt);
|
||||
rv->Assign(1, hbh->ip6h_len);
|
||||
rv->Assign(2, BuildOptionsVal(data + off, Length() - off));
|
||||
|
@ -98,7 +98,7 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
|
||||
static auto ip6_dstopts_type = id::find_type<RecordType>("ip6_dstopts");
|
||||
rv = make_intrusive<RecordVal>(ip6_dstopts_type);
|
||||
const struct ip6_dest* dst = (const struct ip6_dest*)data;
|
||||
const struct ip6_dest* dst = reinterpret_cast<const ip6_dest*>(data);
|
||||
rv->Assign(0, dst->ip6d_nxt);
|
||||
rv->Assign(1, dst->ip6d_len);
|
||||
rv->Assign(2, BuildOptionsVal(data + off, Length() - off));
|
||||
|
@ -111,7 +111,7 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
|
||||
static auto ip6_routing_type = id::find_type<RecordType>("ip6_routing");
|
||||
rv = make_intrusive<RecordVal>(ip6_routing_type);
|
||||
const struct ip6_rthdr* rt = (const struct ip6_rthdr*)data;
|
||||
const struct ip6_rthdr* rt = reinterpret_cast<const ip6_rthdr*>(data);
|
||||
rv->Assign(0, rt->ip6r_nxt);
|
||||
rv->Assign(1, rt->ip6r_len);
|
||||
rv->Assign(2, rt->ip6r_type);
|
||||
|
@ -122,7 +122,7 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
case IPPROTO_FRAGMENT: {
|
||||
static auto ip6_fragment_type = id::find_type<RecordType>("ip6_fragment");
|
||||
rv = make_intrusive<RecordVal>(ip6_fragment_type);
|
||||
const struct ip6_frag* frag = (const struct ip6_frag*)data;
|
||||
const struct ip6_frag* frag = reinterpret_cast<const ip6_frag*>(data);
|
||||
rv->Assign(0, frag->ip6f_nxt);
|
||||
rv->Assign(1, frag->ip6f_reserved);
|
||||
rv->Assign(2, (ntohs(frag->ip6f_offlg) & 0xfff8) >> 3);
|
||||
|
@ -134,15 +134,15 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
case IPPROTO_AH: {
|
||||
static auto ip6_ah_type = id::find_type<RecordType>("ip6_ah");
|
||||
rv = make_intrusive<RecordVal>(ip6_ah_type);
|
||||
rv->Assign(0, ((ip6_ext*)data)->ip6e_nxt);
|
||||
rv->Assign(1, ((ip6_ext*)data)->ip6e_len);
|
||||
rv->Assign(2, ntohs(((uint16_t*)data)[1]));
|
||||
rv->Assign(3, static_cast<uint32_t>(ntohl(((uint32_t*)data)[1])));
|
||||
rv->Assign(0, reinterpret_cast<const ip6_ext*>(data)->ip6e_nxt);
|
||||
rv->Assign(1, reinterpret_cast<const ip6_ext*>(data)->ip6e_len);
|
||||
rv->Assign(2, ntohs(reinterpret_cast<const uint16_t*>(data)[1]));
|
||||
rv->Assign(3, static_cast<uint32_t>(ntohl(reinterpret_cast<const uint32_t*>(data)[1])));
|
||||
|
||||
if ( Length() >= 12 ) {
|
||||
// Sequence Number and ICV fields can only be extracted if
|
||||
// Payload Len was non-zero for this header.
|
||||
rv->Assign(4, static_cast<uint32_t>(ntohl(((uint32_t*)data)[2])));
|
||||
rv->Assign(4, static_cast<uint32_t>(ntohl(reinterpret_cast<const uint32_t*>(data)[2])));
|
||||
uint16_t off = 3 * sizeof(uint32_t);
|
||||
rv->Assign(5, new String(data + off, Length() - off, true));
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
case IPPROTO_ESP: {
|
||||
static auto ip6_esp_type = id::find_type<RecordType>("ip6_esp");
|
||||
rv = make_intrusive<RecordVal>(ip6_esp_type);
|
||||
const uint32_t* esp = (const uint32_t*)data;
|
||||
const uint32_t* esp = reinterpret_cast<const uint32_t*>(data);
|
||||
rv->Assign(0, static_cast<uint32_t>(ntohl(esp[0])));
|
||||
rv->Assign(1, static_cast<uint32_t>(ntohl(esp[1])));
|
||||
} break;
|
||||
|
@ -159,7 +159,7 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
case IPPROTO_MOBILITY: {
|
||||
static auto ip6_mob_type = id::find_type<RecordType>("ip6_mobility_hdr");
|
||||
rv = make_intrusive<RecordVal>(ip6_mob_type);
|
||||
const struct ip6_mobility* mob = (const struct ip6_mobility*)data;
|
||||
const struct ip6_mobility* mob = reinterpret_cast<const ip6_mobility*>(data);
|
||||
rv->Assign(0, mob->ip6mob_payload);
|
||||
rv->Assign(1, mob->ip6mob_len);
|
||||
rv->Assign(2, mob->ip6mob_type);
|
||||
|
@ -189,7 +189,7 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
break;
|
||||
|
||||
auto m = make_intrusive<RecordVal>(ip6_mob_brr_type);
|
||||
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
||||
m->Assign(0, ntohs(*reinterpret_cast<const uint16_t*>(msg_data)));
|
||||
m->Assign(1, BuildOptionsVal(data + off, Length() - off));
|
||||
msg->Assign(1, std::move(m));
|
||||
break;
|
||||
|
@ -201,8 +201,8 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
break;
|
||||
|
||||
auto m = make_intrusive<RecordVal>(ip6_mob_hoti_type);
|
||||
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
||||
m->Assign(1, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))));
|
||||
m->Assign(0, ntohs(*(reinterpret_cast<const uint16_t*>(msg_data))));
|
||||
m->Assign(1, ntohll(*reinterpret_cast<const uint64_t*>(msg_data + sizeof(uint16_t))));
|
||||
m->Assign(2, BuildOptionsVal(data + off, Length() - off));
|
||||
msg->Assign(2, std::move(m));
|
||||
break;
|
||||
|
@ -214,8 +214,8 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
break;
|
||||
|
||||
auto m = make_intrusive<RecordVal>(ip6_mob_coti_type);
|
||||
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
||||
m->Assign(1, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))));
|
||||
m->Assign(0, ntohs(*reinterpret_cast<const uint16_t*>(msg_data)));
|
||||
m->Assign(1, ntohll(*reinterpret_cast<const uint64_t*>(msg_data + sizeof(uint16_t))));
|
||||
m->Assign(2, BuildOptionsVal(data + off, Length() - off));
|
||||
msg->Assign(3, std::move(m));
|
||||
break;
|
||||
|
@ -227,9 +227,10 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
break;
|
||||
|
||||
auto m = make_intrusive<RecordVal>(ip6_mob_hot_type);
|
||||
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
||||
m->Assign(1, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))));
|
||||
m->Assign(2, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t)))));
|
||||
m->Assign(0, ntohs(*reinterpret_cast<const uint16_t*>(msg_data)));
|
||||
m->Assign(1, ntohll(*reinterpret_cast<const uint64_t*>(msg_data + sizeof(uint16_t))));
|
||||
m->Assign(2, ntohll(*reinterpret_cast<const uint64_t*>(msg_data + sizeof(uint16_t) +
|
||||
sizeof(uint64_t))));
|
||||
m->Assign(3, BuildOptionsVal(data + off, Length() - off));
|
||||
msg->Assign(4, std::move(m));
|
||||
break;
|
||||
|
@ -241,9 +242,10 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
break;
|
||||
|
||||
auto m = make_intrusive<RecordVal>(ip6_mob_cot_type);
|
||||
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
||||
m->Assign(1, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t)))));
|
||||
m->Assign(2, ntohll(*((uint64_t*)(msg_data + sizeof(uint16_t) + sizeof(uint64_t)))));
|
||||
m->Assign(0, ntohs(*reinterpret_cast<const uint16_t*>(msg_data)));
|
||||
m->Assign(1, ntohll(*reinterpret_cast<const uint64_t*>(msg_data + sizeof(uint16_t))));
|
||||
m->Assign(2, ntohll(*reinterpret_cast<const uint64_t*>(msg_data + sizeof(uint16_t) +
|
||||
sizeof(uint64_t))));
|
||||
m->Assign(3, BuildOptionsVal(data + off, Length() - off));
|
||||
msg->Assign(5, std::move(m));
|
||||
break;
|
||||
|
@ -255,12 +257,16 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
break;
|
||||
|
||||
auto m = make_intrusive<RecordVal>(ip6_mob_bu_type);
|
||||
m->Assign(0, ntohs(*((uint16_t*)msg_data)));
|
||||
m->Assign(1, static_cast<bool>(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x8000));
|
||||
m->Assign(2, static_cast<bool>(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x4000));
|
||||
m->Assign(3, static_cast<bool>(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x2000));
|
||||
m->Assign(4, static_cast<bool>(ntohs(*((uint16_t*)(msg_data + sizeof(uint16_t)))) & 0x1000));
|
||||
m->Assign(5, ntohs(*((uint16_t*)(msg_data + 2 * sizeof(uint16_t)))));
|
||||
m->Assign(0, ntohs(*reinterpret_cast<const uint16_t*>(msg_data)));
|
||||
m->Assign(1, static_cast<bool>(
|
||||
ntohs(*reinterpret_cast<const uint16_t*>(msg_data + sizeof(uint16_t))) & 0x8000));
|
||||
m->Assign(2, static_cast<bool>(
|
||||
ntohs(*reinterpret_cast<const uint16_t*>(msg_data + sizeof(uint16_t))) & 0x4000));
|
||||
m->Assign(3, static_cast<bool>(
|
||||
ntohs(*reinterpret_cast<const uint16_t*>(msg_data + sizeof(uint16_t))) & 0x2000));
|
||||
m->Assign(4, static_cast<bool>(
|
||||
ntohs(*reinterpret_cast<const uint16_t*>(msg_data + sizeof(uint16_t))) & 0x1000));
|
||||
m->Assign(5, ntohs(*reinterpret_cast<const uint16_t*>(msg_data + 2 * sizeof(uint16_t))));
|
||||
m->Assign(6, BuildOptionsVal(data + off, Length() - off));
|
||||
msg->Assign(6, std::move(m));
|
||||
break;
|
||||
|
@ -272,10 +278,11 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
break;
|
||||
|
||||
auto m = make_intrusive<RecordVal>(ip6_mob_back_type);
|
||||
m->Assign(0, *((uint8_t*)msg_data));
|
||||
m->Assign(1, static_cast<bool>(*((uint8_t*)(msg_data + sizeof(uint8_t))) & 0x80));
|
||||
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(0, *(reinterpret_cast<const uint8_t*>(msg_data)));
|
||||
m->Assign(1,
|
||||
static_cast<bool>(*reinterpret_cast<const uint8_t*>(msg_data + sizeof(uint8_t)) & 0x80));
|
||||
m->Assign(2, ntohs(*reinterpret_cast<const uint16_t*>(msg_data + sizeof(uint16_t))));
|
||||
m->Assign(3, ntohs(*reinterpret_cast<const uint16_t*>(msg_data + 2 * sizeof(uint16_t))));
|
||||
m->Assign(4, BuildOptionsVal(data + off, Length() - off));
|
||||
msg->Assign(7, std::move(m));
|
||||
break;
|
||||
|
@ -287,8 +294,8 @@ RecordValPtr IPv6_Hdr::ToVal(VectorValPtr chain) const {
|
|||
break;
|
||||
|
||||
auto m = make_intrusive<RecordVal>(ip6_mob_be_type);
|
||||
m->Assign(0, *((uint8_t*)msg_data));
|
||||
const in6_addr* hoa = (const in6_addr*)(msg_data + sizeof(uint16_t));
|
||||
m->Assign(0, *reinterpret_cast<const uint8_t*>(msg_data));
|
||||
const in6_addr* hoa = reinterpret_cast<const in6_addr*>(msg_data + sizeof(uint16_t));
|
||||
m->Assign(1, make_intrusive<AddrVal>(IPAddr(*hoa)));
|
||||
m->Assign(2, BuildOptionsVal(data + off, Length() - off));
|
||||
msg->Assign(8, std::move(m));
|
||||
|
@ -367,7 +374,7 @@ RecordValPtr IP_Hdr::ToPktHdrVal(RecordValPtr pkt_hdr, int sindex) const {
|
|||
if ( PayloadLen() < sizeof(struct tcphdr) )
|
||||
break;
|
||||
|
||||
const struct tcphdr* tp = (const struct tcphdr*)data;
|
||||
const struct tcphdr* tp = reinterpret_cast<const tcphdr*>(data);
|
||||
auto tcp_hdr = make_intrusive<RecordVal>(tcp_hdr_type);
|
||||
|
||||
int tcp_hdr_len = tp->th_off * 4;
|
||||
|
@ -397,7 +404,7 @@ RecordValPtr IP_Hdr::ToPktHdrVal(RecordValPtr pkt_hdr, int sindex) const {
|
|||
if ( PayloadLen() < sizeof(struct udphdr) )
|
||||
break;
|
||||
|
||||
const struct udphdr* up = (const struct udphdr*)data;
|
||||
const struct udphdr* up = reinterpret_cast<const udphdr*>(data);
|
||||
auto udp_hdr = make_intrusive<RecordVal>(udp_hdr_type);
|
||||
|
||||
udp_hdr->Assign(0, val_mgr->Port(ntohs(up->uh_sport), TRANSPORT_UDP));
|
||||
|
@ -412,7 +419,7 @@ RecordValPtr IP_Hdr::ToPktHdrVal(RecordValPtr pkt_hdr, int sindex) const {
|
|||
if ( PayloadLen() < sizeof(struct icmp) )
|
||||
break;
|
||||
|
||||
const struct icmp* icmpp = (const struct icmp*)data;
|
||||
const struct icmp* icmpp = reinterpret_cast<const icmp*>(data);
|
||||
auto icmp_hdr = make_intrusive<RecordVal>(icmp_hdr_type);
|
||||
|
||||
icmp_hdr->Assign(0, icmpp->icmp_type);
|
||||
|
@ -425,7 +432,7 @@ RecordValPtr IP_Hdr::ToPktHdrVal(RecordValPtr pkt_hdr, int sindex) const {
|
|||
if ( PayloadLen() < sizeof(struct icmp6_hdr) )
|
||||
break;
|
||||
|
||||
const struct icmp6_hdr* icmpp = (const struct icmp6_hdr*)data;
|
||||
const struct icmp6_hdr* icmpp = reinterpret_cast<const icmp6_hdr*>(data);
|
||||
auto icmp_hdr = make_intrusive<RecordVal>(icmp_hdr_type);
|
||||
|
||||
icmp_hdr->Assign(0, icmpp->icmp6_type);
|
||||
|
@ -465,7 +472,7 @@ void IPv6_Hdr_Chain::Init(const struct ip6_hdr* ip6, uint64_t total_len, bool se
|
|||
length = 0;
|
||||
uint8_t current_type;
|
||||
uint8_t next_type = IPPROTO_IPV6;
|
||||
const u_char* hdrs = (const u_char*)ip6;
|
||||
const u_char* hdrs = reinterpret_cast<const u_char*>(ip6);
|
||||
|
||||
if ( total_len < (int)sizeof(struct ip6_hdr) ) {
|
||||
reporter->InternalWarning("truncated IP header in IPv6_HdrChain::Init");
|
||||
|
@ -497,11 +504,11 @@ void IPv6_Hdr_Chain::Init(const struct ip6_hdr* ip6, uint64_t total_len, bool se
|
|||
|
||||
// Check for routing headers and remember final destination address.
|
||||
if ( current_type == IPPROTO_ROUTING )
|
||||
ProcessRoutingHeader((const struct ip6_rthdr*)hdrs, cur_len);
|
||||
ProcessRoutingHeader(reinterpret_cast<const ip6_rthdr*>(hdrs), cur_len);
|
||||
|
||||
// Only Mobile IPv6 has a destination option we care about right now.
|
||||
if ( current_type == IPPROTO_DSTOPTS )
|
||||
ProcessDstOpts((const struct ip6_dest*)hdrs, cur_len);
|
||||
ProcessDstOpts(reinterpret_cast<const ip6_dest*>(hdrs), cur_len);
|
||||
|
||||
hdrs += cur_len;
|
||||
length += cur_len;
|
||||
|
@ -529,7 +536,7 @@ IPAddr IPv6_Hdr_Chain::SrcAddr() const {
|
|||
return {};
|
||||
}
|
||||
|
||||
return IPAddr{((const struct ip6_hdr*)(chain[0].Data()))->ip6_src};
|
||||
return IPAddr{reinterpret_cast<const struct ip6_hdr*>(chain[0].Data())->ip6_src};
|
||||
}
|
||||
|
||||
IPAddr IPv6_Hdr_Chain::DstAddr() const {
|
||||
|
@ -541,7 +548,7 @@ IPAddr IPv6_Hdr_Chain::DstAddr() const {
|
|||
return {};
|
||||
}
|
||||
|
||||
return IPAddr{((const struct ip6_hdr*)(chain[0].Data()))->ip6_dst};
|
||||
return IPAddr{reinterpret_cast<const struct ip6_hdr*>(chain[0].Data())->ip6_dst};
|
||||
}
|
||||
|
||||
void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t len) {
|
||||
|
@ -552,7 +559,7 @@ void IPv6_Hdr_Chain::ProcessRoutingHeader(const struct ip6_rthdr* r, uint16_t le
|
|||
}
|
||||
|
||||
// Last 16 bytes of header (for all known types) is the address we want.
|
||||
const in6_addr* addr = (const in6_addr*)(((const u_char*)r) + len - 16);
|
||||
const in6_addr* addr = reinterpret_cast<const in6_addr*>(reinterpret_cast<const u_char*>(r) + len - 16);
|
||||
|
||||
switch ( r->ip6r_type ) {
|
||||
case 0: // Defined by RFC 2460, deprecated by RFC 5095
|
||||
|
@ -589,12 +596,12 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len) {
|
|||
// https://datatracker.ietf.org/doc/html/rfc8200#section-4.6
|
||||
assert(len >= 2);
|
||||
|
||||
const u_char* data = (const u_char*)d;
|
||||
const u_char* data = reinterpret_cast<const u_char*>(d);
|
||||
len -= 2 * sizeof(uint8_t);
|
||||
data += 2 * sizeof(uint8_t);
|
||||
|
||||
while ( len > 0 ) {
|
||||
const struct ip6_opt* opt = (const struct ip6_opt*)data;
|
||||
const struct ip6_opt* opt = reinterpret_cast<const struct ip6_opt*>(data);
|
||||
switch ( opt->ip6o_type ) {
|
||||
case 0:
|
||||
// If option type is zero, it's a Pad0 and can be just a single
|
||||
|
@ -618,7 +625,7 @@ void IPv6_Hdr_Chain::ProcessDstOpts(const struct ip6_dest* d, uint16_t len) {
|
|||
if ( homeAddr )
|
||||
reporter->Weird(SrcAddr(), DstAddr(), "multiple_home_addr_opts");
|
||||
else
|
||||
homeAddr = new IPAddr(*((const in6_addr*)(data + sizeof(struct ip6_opt))));
|
||||
homeAddr = new IPAddr(*reinterpret_cast<const in6_addr*>(data + sizeof(struct ip6_opt)));
|
||||
}
|
||||
else
|
||||
reporter->Weird(SrcAddr(), DstAddr(), "bad_home_addr_len");
|
||||
|
@ -670,11 +677,11 @@ IP_Hdr* IP_Hdr::Copy() const {
|
|||
|
||||
if ( ip4 ) {
|
||||
memcpy(new_hdr, ip4, HdrLen());
|
||||
return new IP_Hdr((const struct ip*)new_hdr, true);
|
||||
return new IP_Hdr(reinterpret_cast<const ip*>(new_hdr), true);
|
||||
}
|
||||
|
||||
memcpy(new_hdr, ip6, HdrLen());
|
||||
const struct ip6_hdr* new_ip6 = (const struct ip6_hdr*)new_hdr;
|
||||
const ip6_hdr* new_ip6 = reinterpret_cast<const ip6_hdr*>(new_hdr);
|
||||
IPv6_Hdr_Chain* new_ip6_hdrs = ip6_hdrs->Copy(new_ip6);
|
||||
return new IP_Hdr(new_ip6, true, 0, new_ip6_hdrs);
|
||||
}
|
||||
|
@ -695,7 +702,7 @@ IPv6_Hdr_Chain* IPv6_Hdr_Chain::Copy(const ip6_hdr* new_hdr) const {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const u_char* new_data = (const u_char*)new_hdr;
|
||||
const u_char* new_data = reinterpret_cast<const u_char*>(new_hdr);
|
||||
const u_char* old_data = chain[0].Data();
|
||||
|
||||
for ( const auto& c : chain ) {
|
||||
|
|
35
src/IP.h
35
src/IP.h
|
@ -62,13 +62,16 @@ public:
|
|||
*/
|
||||
void ChangeNext(uint8_t next_type) {
|
||||
switch ( type ) {
|
||||
case IPPROTO_IPV6: ((ip6_hdr*)data)->ip6_nxt = next_type; break;
|
||||
data;
|
||||
case IPPROTO_IPV6: const_cast<ip6_hdr*>(reinterpret_cast<const ip6_hdr*>(data))->ip6_nxt = next_type; break;
|
||||
case IPPROTO_HOPOPTS:
|
||||
case IPPROTO_DSTOPTS:
|
||||
case IPPROTO_ROUTING:
|
||||
case IPPROTO_FRAGMENT:
|
||||
case IPPROTO_AH:
|
||||
case IPPROTO_MOBILITY: ((ip6_ext*)data)->ip6e_nxt = next_type; break;
|
||||
case IPPROTO_MOBILITY:
|
||||
const_cast<ip6_ext*>(reinterpret_cast<const ip6_ext*>(data))->ip6e_nxt = next_type;
|
||||
break;
|
||||
case IPPROTO_ESP:
|
||||
default: break;
|
||||
}
|
||||
|
@ -82,13 +85,13 @@ public:
|
|||
*/
|
||||
uint8_t NextHdr() const {
|
||||
switch ( type ) {
|
||||
case IPPROTO_IPV6: return ((ip6_hdr*)data)->ip6_nxt;
|
||||
case IPPROTO_IPV6: return (reinterpret_cast<const ip6_hdr*>(data))->ip6_nxt;
|
||||
case IPPROTO_HOPOPTS:
|
||||
case IPPROTO_DSTOPTS:
|
||||
case IPPROTO_ROUTING:
|
||||
case IPPROTO_FRAGMENT:
|
||||
case IPPROTO_AH:
|
||||
case IPPROTO_MOBILITY: return ((ip6_ext*)data)->ip6e_nxt;
|
||||
case IPPROTO_MOBILITY: return (reinterpret_cast<const ip6_ext*>(data))->ip6e_nxt;
|
||||
case IPPROTO_ESP:
|
||||
default: return IPPROTO_NONE;
|
||||
}
|
||||
|
@ -103,9 +106,9 @@ public:
|
|||
case IPPROTO_HOPOPTS:
|
||||
case IPPROTO_DSTOPTS:
|
||||
case IPPROTO_ROUTING:
|
||||
case IPPROTO_MOBILITY: return 8 + 8 * ((ip6_ext*)data)->ip6e_len;
|
||||
case IPPROTO_MOBILITY: return 8 + 8 * (reinterpret_cast<const ip6_ext*>(data))->ip6e_len;
|
||||
case IPPROTO_FRAGMENT: return 8;
|
||||
case IPPROTO_AH: return 8 + 4 * ((ip6_ext*)data)->ip6e_len;
|
||||
case IPPROTO_AH: return 8 + 4 * (reinterpret_cast<const ip6_ext*>(data))->ip6e_len;
|
||||
case IPPROTO_ESP: return 8; // encrypted payload begins after 8 bytes
|
||||
default: return 0;
|
||||
}
|
||||
|
@ -174,7 +177,7 @@ public:
|
|||
* Returns pointer to fragment header structure if the chain contains one.
|
||||
*/
|
||||
const struct ip6_frag* GetFragHdr() const {
|
||||
return IsFragment() ? (const struct ip6_frag*)chain[chain.size() - 1].Data() : nullptr;
|
||||
return IsFragment() ? reinterpret_cast<const ip6_frag*>(chain[chain.size() - 1].Data()) : nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,7 +280,7 @@ public:
|
|||
* @param arg_del whether to take ownership of \a arg_ip4 pointer's memory.
|
||||
* @param reassembled whether this header is for a reassembled packet.
|
||||
*/
|
||||
IP_Hdr(const struct ip* arg_ip4, bool arg_del, bool reassembled = false)
|
||||
IP_Hdr(const ip* arg_ip4, bool arg_del, bool reassembled = false)
|
||||
: ip4(arg_ip4), del(arg_del), reassembled(reassembled) {}
|
||||
|
||||
/**
|
||||
|
@ -292,7 +295,7 @@ public:
|
|||
* @param c an already-constructed header chain to take ownership of.
|
||||
* @param reassembled whether this header is for a reassembled packet.
|
||||
*/
|
||||
IP_Hdr(const struct ip6_hdr* arg_ip6, bool arg_del, uint64_t len, const IPv6_Hdr_Chain* c = nullptr,
|
||||
IP_Hdr(const ip6_hdr* arg_ip6, bool arg_del, uint64_t len, const IPv6_Hdr_Chain* c = nullptr,
|
||||
bool reassembled = false)
|
||||
: ip6(arg_ip6), ip6_hdrs(c ? c : new IPv6_Hdr_Chain(ip6, len)), del(arg_del), reassembled(reassembled) {}
|
||||
|
||||
|
@ -310,8 +313,8 @@ public:
|
|||
delete ip6_hdrs;
|
||||
|
||||
if ( del ) {
|
||||
delete[] (struct ip*)ip4;
|
||||
delete[] (struct ip6_hdr*)ip6;
|
||||
delete[] ip4;
|
||||
delete[] ip6;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -356,9 +359,9 @@ public:
|
|||
*/
|
||||
const u_char* Payload() const {
|
||||
if ( ip4 )
|
||||
return ((const u_char*)ip4) + (ip4->ip_hl * static_cast<std::ptrdiff_t>(4));
|
||||
return (reinterpret_cast<const u_char*>(ip4)) + (ip4->ip_hl * static_cast<std::ptrdiff_t>(4));
|
||||
|
||||
return ((const u_char*)ip6) + ip6_hdrs->TotalLength();
|
||||
return (reinterpret_cast<const u_char*>(ip6)) + ip6_hdrs->TotalLength();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -371,7 +374,7 @@ public:
|
|||
else if ( (*ip6_hdrs)[ip6_hdrs->Size() - 1]->Type() != IPPROTO_MOBILITY )
|
||||
return nullptr;
|
||||
else
|
||||
return (const ip6_mobility*)(*ip6_hdrs)[ip6_hdrs->Size() - 1]->Data();
|
||||
return reinterpret_cast<const ip6_mobility*>((*ip6_hdrs)[ip6_hdrs->Size() - 1]->Data());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -498,8 +501,8 @@ public:
|
|||
bool Reassembled() const { return reassembled; }
|
||||
|
||||
private:
|
||||
const struct ip* ip4 = nullptr;
|
||||
const struct ip6_hdr* ip6 = nullptr;
|
||||
const ip* ip4 = nullptr;
|
||||
const ip6_hdr* ip6 = nullptr;
|
||||
const IPv6_Hdr_Chain* ip6_hdrs = nullptr;
|
||||
bool del = false;
|
||||
bool reassembled = false;
|
||||
|
|
|
@ -132,11 +132,11 @@ std::string IPAddr::AsHexString() const {
|
|||
char buf[33];
|
||||
|
||||
if ( GetFamily() == IPv4 ) {
|
||||
uint32_t* p = (uint32_t*)&in6.s6_addr[12];
|
||||
const uint32_t* p = reinterpret_cast<const uint32_t*>(&in6.s6_addr[12]);
|
||||
snprintf(buf, sizeof(buf), "%08x", (uint32_t)ntohl(*p));
|
||||
}
|
||||
else {
|
||||
uint32_t* p = (uint32_t*)in6.s6_addr;
|
||||
const uint32_t* p = reinterpret_cast<const uint32_t*>(in6.s6_addr);
|
||||
snprintf(buf, sizeof(buf), "%08x%08x%08x%08x", (uint32_t)ntohl(p[0]), (uint32_t)ntohl(p[1]),
|
||||
(uint32_t)ntohl(p[2]), (uint32_t)ntohl(p[3]));
|
||||
}
|
||||
|
@ -147,7 +147,7 @@ std::string IPAddr::AsHexString() const {
|
|||
std::string IPAddr::PtrName() const {
|
||||
if ( GetFamily() == IPv4 ) {
|
||||
char buf[256];
|
||||
uint32_t* p = (uint32_t*)&in6.s6_addr[12];
|
||||
const uint32_t* p = reinterpret_cast<const uint32_t*>(&in6.s6_addr[12]);
|
||||
uint32_t a = ntohl(*p);
|
||||
uint32_t a3 = (a >> 24) & 0xff;
|
||||
uint32_t a2 = (a >> 16) & 0xff;
|
||||
|
@ -159,7 +159,7 @@ std::string IPAddr::PtrName() const {
|
|||
else {
|
||||
static const char hex_digit[] = "0123456789abcdef";
|
||||
std::string ptr_name("ip6.arpa");
|
||||
uint32_t* p = (uint32_t*)in6.s6_addr;
|
||||
const uint32_t* p = reinterpret_cast<const uint32_t*>(in6.s6_addr);
|
||||
|
||||
for ( unsigned int i = 0; i < 4; ++i ) {
|
||||
uint32_t a = ntohl(p[i]);
|
||||
|
|
|
@ -162,11 +162,11 @@ public:
|
|||
*/
|
||||
int GetBytes(const uint32_t** bytes) const {
|
||||
if ( GetFamily() == IPv4 ) {
|
||||
*bytes = (uint32_t*)&in6.s6_addr[12];
|
||||
*bytes = reinterpret_cast<const uint32_t*>(&in6.s6_addr[12]);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
*bytes = (uint32_t*)in6.s6_addr;
|
||||
*bytes = reinterpret_cast<const uint32_t*>(in6.s6_addr);
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
@ -393,7 +393,7 @@ inline IPAddr::IPAddr(Family family, const uint32_t* bytes, ByteOrder order) {
|
|||
memcpy(&in6.s6_addr[12], bytes, sizeof(uint32_t));
|
||||
|
||||
if ( order == Host ) {
|
||||
uint32_t* p = (uint32_t*)&in6.s6_addr[12];
|
||||
uint32_t* p = reinterpret_cast<uint32_t*>(&in6.s6_addr[12]);
|
||||
*p = htonl(*p);
|
||||
}
|
||||
}
|
||||
|
@ -403,7 +403,7 @@ inline IPAddr::IPAddr(Family family, const uint32_t* bytes, ByteOrder order) {
|
|||
|
||||
if ( order == Host ) {
|
||||
for ( unsigned int i = 0; i < 4; ++i ) {
|
||||
uint32_t* p = (uint32_t*)&in6.s6_addr[i * static_cast<ptrdiff_t>(4)];
|
||||
uint32_t* p = reinterpret_cast<uint32_t*>(&in6.s6_addr[i * static_cast<ptrdiff_t>(4)]);
|
||||
*p = htonl(*p);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,18 +129,18 @@ bool MMDB::Lookup(const zeek::IPAddr& addr, MMDB_lookup_result_s& result) {
|
|||
struct sockaddr_storage ss = {0};
|
||||
|
||||
if ( IPv4 == addr.GetFamily() ) {
|
||||
struct sockaddr_in* sa = (struct sockaddr_in*)&ss;
|
||||
struct sockaddr_in* sa = reinterpret_cast<sockaddr_in*>(&ss);
|
||||
sa->sin_family = AF_INET;
|
||||
addr.CopyIPv4(&sa->sin_addr);
|
||||
}
|
||||
else {
|
||||
struct sockaddr_in6* sa = (struct sockaddr_in6*)&ss;
|
||||
struct sockaddr_in6* sa = reinterpret_cast<sockaddr_in6*>(&ss);
|
||||
sa->sin6_family = AF_INET6;
|
||||
addr.CopyIPv6(&sa->sin6_addr);
|
||||
}
|
||||
|
||||
int mmdb_error;
|
||||
result = MMDB_lookup_sockaddr(&mmdb, (struct sockaddr*)&ss, &mmdb_error);
|
||||
result = MMDB_lookup_sockaddr(&mmdb, reinterpret_cast<sockaddr*>(&ss), &mmdb_error);
|
||||
|
||||
if ( MMDB_SUCCESS != mmdb_error ) {
|
||||
report_msg("MaxMind DB lookup location error [%s]", MMDB_strerror(mmdb_error));
|
||||
|
|
|
@ -188,6 +188,6 @@ void bad_ref(int type) {
|
|||
abort();
|
||||
}
|
||||
|
||||
void obj_delete_func(void* v) { Unref((Obj*)v); }
|
||||
void obj_delete_func(void* v) { Unref(reinterpret_cast<Obj*>(v)); }
|
||||
|
||||
} // namespace zeek
|
||||
|
|
|
@ -74,11 +74,11 @@ bool PacketFilter::RemoveDst(Val* dst) {
|
|||
}
|
||||
|
||||
bool PacketFilter::Match(const std::shared_ptr<IP_Hdr>& ip, int len, int caplen) {
|
||||
Filter* f = (Filter*)src_filter.Lookup(ip->SrcAddr(), 128);
|
||||
Filter* f = reinterpret_cast<Filter*>(src_filter.Lookup(ip->SrcAddr(), 128));
|
||||
if ( f )
|
||||
return MatchFilter(*f, *ip, len, caplen);
|
||||
|
||||
f = (Filter*)dst_filter.Lookup(ip->DstAddr(), 128);
|
||||
f = reinterpret_cast<Filter*>(dst_filter.Lookup(ip->DstAddr(), 128));
|
||||
if ( f )
|
||||
return MatchFilter(*f, *ip, len, caplen);
|
||||
|
||||
|
@ -96,7 +96,7 @@ bool PacketFilter::MatchFilter(const Filter& f, const IP_Hdr& ip, int len, int c
|
|||
// Packet too short, will be dropped anyway.
|
||||
return false;
|
||||
|
||||
const struct tcphdr* tp = (const struct tcphdr*)ip.Payload();
|
||||
const struct tcphdr* tp = reinterpret_cast<const tcphdr*>(ip.Payload());
|
||||
|
||||
if ( tp->th_flags & f.tcp_flags )
|
||||
// At least one of the flags is set, so don't drop
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
namespace zeek::detail {
|
||||
|
||||
prefix_t* PrefixTable::MakePrefix(const IPAddr& addr, int width) {
|
||||
prefix_t* prefix = (prefix_t*)util::safe_malloc(sizeof(prefix_t));
|
||||
prefix_t* prefix = reinterpret_cast<prefix_t*>(util::safe_malloc(sizeof(prefix_t)));
|
||||
|
||||
addr.CopyIPv6(&prefix->add.sin6);
|
||||
prefix->family = AF_INET6;
|
||||
|
|
|
@ -541,7 +541,7 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Conne
|
|||
new_buffer_size++;
|
||||
|
||||
if ( new_buffer_size > DEFAULT_BUFFER_SIZE ) {
|
||||
buffer = (char*)malloc(new_buffer_size);
|
||||
buffer = reinterpret_cast<char*>(malloc(new_buffer_size));
|
||||
if ( ! buffer ) {
|
||||
va_end(ap_copy);
|
||||
FatalError("out of memory in Reporter");
|
||||
|
|
|
@ -162,7 +162,7 @@ bool RuleConditionEval::DoMatch(Rule* rule, RuleEndpointState* state, const u_ch
|
|||
args.emplace_back(AdoptRef{}, rule_matcher->BuildRuleStateValue(rule, state));
|
||||
|
||||
if ( data )
|
||||
args.emplace_back(make_intrusive<StringVal>(len, (const char*)data));
|
||||
args.emplace_back(make_intrusive<StringVal>(len, reinterpret_cast<const char*>(data)));
|
||||
else
|
||||
args.emplace_back(val_mgr->EmptyString());
|
||||
|
||||
|
|
|
@ -485,11 +485,11 @@ void RuleMatcher::BuildPatternSets(RuleHdrTest::pattern_set_list* dst, const str
|
|||
// Get a 8/16/32-bit value from the given position in the packet header
|
||||
static inline uint32_t getval(const u_char* data, int size) {
|
||||
switch ( size ) {
|
||||
case 1: return *(uint8_t*)data;
|
||||
case 1: return *reinterpret_cast<const uint8_t*>(data);
|
||||
|
||||
case 2: return ntohs(*(uint16_t*)data);
|
||||
case 2: return ntohs(*reinterpret_cast<const uint16_t*>(data));
|
||||
|
||||
case 4: return ntohl(*(uint32_t*)data);
|
||||
case 4: return ntohl(*reinterpret_cast<const uint32_t*>(data));
|
||||
|
||||
default: reporter->InternalError("illegal HdrTest size");
|
||||
}
|
||||
|
@ -735,14 +735,18 @@ RuleEndpointState* RuleMatcher::InitEndpoint(analyzer::Analyzer* analyzer, const
|
|||
if ( ! ip->IP4_Hdr() )
|
||||
continue;
|
||||
|
||||
match = compare(*h->vals, getval((const u_char*)ip->IP4_Hdr() + h->offset, h->size), h->comp);
|
||||
match = compare(*h->vals,
|
||||
getval(reinterpret_cast<const u_char*>(ip->IP4_Hdr()) + h->offset, h->size),
|
||||
h->comp);
|
||||
break;
|
||||
|
||||
case RuleHdrTest::IPv6:
|
||||
if ( ! ip->IP6_Hdr() )
|
||||
continue;
|
||||
|
||||
match = compare(*h->vals, getval((const u_char*)ip->IP6_Hdr() + h->offset, h->size), h->comp);
|
||||
match = compare(*h->vals,
|
||||
getval(reinterpret_cast<const u_char*>(ip->IP6_Hdr()) + h->offset, h->size),
|
||||
h->comp);
|
||||
break;
|
||||
|
||||
case RuleHdrTest::ICMP:
|
||||
|
@ -769,7 +773,7 @@ RuleEndpointState* RuleMatcher::InitEndpoint(analyzer::Analyzer* analyzer, const
|
|||
state->matchers.resize(0);
|
||||
|
||||
// Send BOL to payload matchers.
|
||||
Match(state, Rule::PAYLOAD, (const u_char*)"", 0, true, false, false);
|
||||
Match(state, Rule::PAYLOAD, reinterpret_cast<const u_char*>(""), 0, true, false, false);
|
||||
|
||||
return state;
|
||||
}
|
||||
|
@ -790,7 +794,7 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, const
|
|||
|
||||
#ifdef DEBUG
|
||||
if ( debug_logger.IsEnabled(DBG_RULES) ) {
|
||||
const char* s = util::fmt_bytes((const char*)data, min(40, data_len));
|
||||
const char* s = util::fmt_bytes(reinterpret_cast<const char*>(data), min(40, data_len));
|
||||
|
||||
DBG_LOG(DBG_RULES, "Matching %s rules [%d,%d] on |%s%s|", Rule::TypeToString(type), bol, eol, s,
|
||||
data_len > 40 ? "..." : "");
|
||||
|
@ -889,7 +893,7 @@ void RuleMatcher::Match(RuleEndpointState* state, Rule::PatternType type, const
|
|||
|
||||
void RuleMatcher::FinishEndpoint(RuleEndpointState* state) {
|
||||
// Send EOL to payload matchers.
|
||||
Match(state, Rule::PAYLOAD, (const u_char*)"", 0, false, true, false);
|
||||
Match(state, Rule::PAYLOAD, reinterpret_cast<const u_char*>(""), 0, false, true, false);
|
||||
|
||||
// Some of the pure rules may match at the end of the connection,
|
||||
// although they have not matched at the beginning. So, we have
|
||||
|
|
|
@ -32,7 +32,7 @@ void SerializationFormat::StartWrite() {
|
|||
}
|
||||
|
||||
if ( ! output ) {
|
||||
output = (char*)util::safe_malloc(INITIAL_SIZE);
|
||||
output = reinterpret_cast<char*>(util::safe_malloc(INITIAL_SIZE));
|
||||
output_size = INITIAL_SIZE;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ bool SerializationFormat::WriteData(const void* b, size_t count) {
|
|||
// size is a no-op, but the same claim can't be made on other platforms.
|
||||
// There's really no reason to do that though.
|
||||
if ( size_changed )
|
||||
output = (char*)util::safe_realloc(output, output_size);
|
||||
output = reinterpret_cast<char*>(util::safe_realloc(output, output_size));
|
||||
|
||||
memcpy(output + output_pos, b, count);
|
||||
output_pos += count;
|
||||
|
@ -251,7 +251,7 @@ bool BinarySerializationFormat::Read(struct in_addr* addr, const char* tag) {
|
|||
}
|
||||
|
||||
bool BinarySerializationFormat::Read(struct in6_addr* addr, const char* tag) {
|
||||
uint32_t* bytes = (uint32_t*)&addr->s6_addr;
|
||||
uint32_t* bytes = reinterpret_cast<uint32_t*>(&addr->s6_addr);
|
||||
|
||||
for ( int i = 0; i < 4; ++i ) {
|
||||
if ( ! Read(&bytes[i], "addr6-part") )
|
||||
|
@ -340,7 +340,7 @@ bool BinarySerializationFormat::Write(const IPPrefix& prefix, const char* tag) {
|
|||
}
|
||||
|
||||
bool BinarySerializationFormat::Write(const struct in_addr& addr, const char* tag) {
|
||||
const uint32_t* bytes = (uint32_t*)&addr.s_addr;
|
||||
const uint32_t* bytes = reinterpret_cast<const uint32_t*>(&addr.s_addr);
|
||||
|
||||
if ( ! Write(static_cast<uint32_t>(ntohl(bytes[0])), "addr4") )
|
||||
return false;
|
||||
|
@ -349,7 +349,7 @@ bool BinarySerializationFormat::Write(const struct in_addr& addr, const char* ta
|
|||
}
|
||||
|
||||
bool BinarySerializationFormat::Write(const struct in6_addr& addr, const char* tag) {
|
||||
const uint32_t* bytes = (uint32_t*)&addr.s6_addr;
|
||||
const uint32_t* bytes = reinterpret_cast<const uint32_t*>(&addr.s6_addr);
|
||||
|
||||
for ( int i = 0; i < 4; ++i ) {
|
||||
if ( ! Write(static_cast<uint32_t>(ntohl(bytes[i])), "addr6-part") )
|
||||
|
|
40
src/Stmt.cc
40
src/Stmt.cc
|
@ -73,77 +73,77 @@ Stmt::~Stmt() { delete opt_info; }
|
|||
|
||||
StmtList* Stmt::AsStmtList() {
|
||||
CHECK_TAG(tag, STMT_LIST, "Stmt::AsStmtList", stmt_name)
|
||||
return (StmtList*)this;
|
||||
return static_cast<StmtList*>(this);
|
||||
}
|
||||
|
||||
const StmtList* Stmt::AsStmtList() const {
|
||||
CHECK_TAG(tag, STMT_LIST, "Stmt::AsStmtList", stmt_name)
|
||||
return (const StmtList*)this;
|
||||
return static_cast<const StmtList*>(this);
|
||||
}
|
||||
|
||||
ForStmt* Stmt::AsForStmt() {
|
||||
CHECK_TAG(tag, STMT_FOR, "Stmt::AsForStmt", stmt_name)
|
||||
return (ForStmt*)this;
|
||||
return static_cast<ForStmt*>(this);
|
||||
}
|
||||
|
||||
const ForStmt* Stmt::AsForStmt() const {
|
||||
CHECK_TAG(tag, STMT_FOR, "Stmt::AsForStmt", stmt_name)
|
||||
return (const ForStmt*)this;
|
||||
return static_cast<const ForStmt*>(this);
|
||||
}
|
||||
|
||||
const InitStmt* Stmt::AsInitStmt() const {
|
||||
CHECK_TAG(tag, STMT_INIT, "Stmt::AsInitStmt", stmt_name)
|
||||
return (const InitStmt*)this;
|
||||
return static_cast<const InitStmt*>(this);
|
||||
}
|
||||
|
||||
const IfStmt* Stmt::AsIfStmt() const {
|
||||
CHECK_TAG(tag, STMT_IF, "Stmt::AsIfStmt", stmt_name)
|
||||
return (const IfStmt*)this;
|
||||
return static_cast<const IfStmt*>(this);
|
||||
}
|
||||
|
||||
const WhileStmt* Stmt::AsWhileStmt() const {
|
||||
CHECK_TAG(tag, STMT_WHILE, "Stmt::AsWhileStmt", stmt_name)
|
||||
return (const WhileStmt*)this;
|
||||
return static_cast<const WhileStmt*>(this);
|
||||
}
|
||||
|
||||
const WhenStmt* Stmt::AsWhenStmt() const {
|
||||
CHECK_TAG(tag, STMT_WHEN, "Stmt::AsWhenStmt", stmt_name)
|
||||
return (const WhenStmt*)this;
|
||||
return static_cast<const WhenStmt*>(this);
|
||||
}
|
||||
|
||||
const SwitchStmt* Stmt::AsSwitchStmt() const {
|
||||
CHECK_TAG(tag, STMT_SWITCH, "Stmt::AsSwitchStmt", stmt_name)
|
||||
return (const SwitchStmt*)this;
|
||||
return static_cast<const SwitchStmt*>(this);
|
||||
}
|
||||
|
||||
const ExprStmt* Stmt::AsExprStmt() const {
|
||||
CHECK_TAG(tag, STMT_EXPR, "Stmt::AsExprStmt", stmt_name)
|
||||
return (const ExprStmt*)this;
|
||||
return static_cast<const ExprStmt*>(this);
|
||||
}
|
||||
|
||||
const PrintStmt* Stmt::AsPrintStmt() const {
|
||||
CHECK_TAG(tag, STMT_PRINT, "Stmt::AsPrintStmt", stmt_name)
|
||||
return (const PrintStmt*)this;
|
||||
return static_cast<const PrintStmt*>(this);
|
||||
}
|
||||
|
||||
const CatchReturnStmt* Stmt::AsCatchReturnStmt() const {
|
||||
CHECK_TAG(tag, STMT_CATCH_RETURN, "Stmt::AsCatchReturnStmt", stmt_name)
|
||||
return (const CatchReturnStmt*)this;
|
||||
return static_cast<const CatchReturnStmt*>(this);
|
||||
}
|
||||
|
||||
const ReturnStmt* Stmt::AsReturnStmt() const {
|
||||
CHECK_TAG(tag, STMT_RETURN, "Stmt::AsReturnStmt", stmt_name)
|
||||
return (const ReturnStmt*)this;
|
||||
return static_cast<const ReturnStmt*>(this);
|
||||
}
|
||||
|
||||
const NullStmt* Stmt::AsNullStmt() const {
|
||||
CHECK_TAG(tag, STMT_NULL, "Stmt::AsNullStmt", stmt_name)
|
||||
return (const NullStmt*)this;
|
||||
return static_cast<const NullStmt*>(this);
|
||||
}
|
||||
|
||||
const AssertStmt* Stmt::AsAssertStmt() const {
|
||||
CHECK_TAG(tag, STMT_ASSERT, "Stmt::AsAssertStmt", stmt_name)
|
||||
return (const AssertStmt*)this;
|
||||
return static_cast<const AssertStmt*>(this);
|
||||
}
|
||||
|
||||
bool Stmt::SetLocationInfo(const Location* start, const Location* end) {
|
||||
|
@ -630,7 +630,7 @@ TraversalCode Case::Traverse(TraversalCallback* cb) const {
|
|||
return TC_CONTINUE;
|
||||
}
|
||||
|
||||
static void int_del_func(void* v) { delete (int*)v; }
|
||||
static void int_del_func(void* v) { delete reinterpret_cast<int*>(v); }
|
||||
|
||||
void SwitchStmt::Init() {
|
||||
auto t = make_intrusive<TypeList>();
|
||||
|
@ -672,21 +672,21 @@ SwitchStmt::SwitchStmt(ExprPtr index, case_list* arg_cases)
|
|||
switch ( expr->Tag() ) {
|
||||
// Simplify trivial unary plus/minus expressions on consts.
|
||||
case EXPR_NEGATE: {
|
||||
NegExpr* ne = (NegExpr*)(expr);
|
||||
NegExpr* ne = static_cast<NegExpr*>(expr);
|
||||
|
||||
if ( ne->Op()->IsConst() )
|
||||
Unref(exprs.replace(j, new ConstExpr(ne->Eval(nullptr))));
|
||||
} break;
|
||||
|
||||
case EXPR_POSITIVE: {
|
||||
PosExpr* pe = (PosExpr*)(expr);
|
||||
PosExpr* pe = static_cast<PosExpr*>(expr);
|
||||
|
||||
if ( pe->Op()->IsConst() )
|
||||
Unref(exprs.replace(j, new ConstExpr(pe->Eval(nullptr))));
|
||||
} break;
|
||||
|
||||
case EXPR_NAME: {
|
||||
NameExpr* ne = (NameExpr*)(expr);
|
||||
NameExpr* ne = static_cast<NameExpr*>(expr);
|
||||
|
||||
if ( ne->Id()->IsConst() ) {
|
||||
auto v = ne->Eval(nullptr);
|
||||
|
@ -1195,7 +1195,7 @@ ValPtr ForStmt::DoExec(Frame* f, Val* v, StmtFlowType& flow) {
|
|||
StringVal* sval = v->AsStringVal();
|
||||
|
||||
for ( int i = 0; i < sval->Len(); ++i ) {
|
||||
auto sv = make_intrusive<StringVal>(1, (const char*)sval->Bytes() + i);
|
||||
auto sv = make_intrusive<StringVal>(1, reinterpret_cast<const char*>(sval->Bytes()) + i);
|
||||
f->SetElement((*loop_vars)[0], std::move(sv));
|
||||
flow = FLOW_NEXT;
|
||||
ret = body->Exec(f, flow);
|
||||
|
|
|
@ -175,8 +175,8 @@ double TimerMgr::GetNextTimeout() {
|
|||
return -1;
|
||||
}
|
||||
|
||||
Timer* TimerMgr::Remove() { return (Timer*)q->Remove(); }
|
||||
Timer* TimerMgr::Remove() { return static_cast<Timer*>(q->Remove()); }
|
||||
|
||||
Timer* TimerMgr::Top() { return (Timer*)q->Top(); }
|
||||
Timer* TimerMgr::Top() { return static_cast<Timer*>(q->Top()); }
|
||||
|
||||
} // namespace zeek::detail
|
||||
|
|
84
src/Type.cc
84
src/Type.cc
|
@ -76,22 +76,22 @@ Type::Type(TypeTag t, bool arg_base_type)
|
|||
|
||||
const TypeList* Type::AsTypeList() const {
|
||||
CHECK_TYPE_TAG(TYPE_LIST, "Type::AsTypeList");
|
||||
return (const TypeList*)this;
|
||||
return static_cast<const TypeList*>(this);
|
||||
}
|
||||
|
||||
TypeList* Type::AsTypeList() {
|
||||
CHECK_TYPE_TAG(TYPE_LIST, "Type::AsTypeList");
|
||||
return (TypeList*)this;
|
||||
return static_cast<TypeList*>(this);
|
||||
}
|
||||
|
||||
const TableType* Type::AsTableType() const {
|
||||
CHECK_TYPE_TAG(TYPE_TABLE, "Type::AsTableType");
|
||||
return (const TableType*)this;
|
||||
return static_cast<const TableType*>(this);
|
||||
}
|
||||
|
||||
TableType* Type::AsTableType() {
|
||||
CHECK_TYPE_TAG(TYPE_TABLE, "Type::AsTableType");
|
||||
return (TableType*)this;
|
||||
return static_cast<TableType*>(this);
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
@ -101,13 +101,13 @@ TableType* Type::AsTableType() {
|
|||
const SetType* Type::AsSetType() const {
|
||||
if ( ! IsSet() )
|
||||
BadTag("Type::AsSetType", type_name(tag));
|
||||
return (const SetType*)this;
|
||||
return static_cast<const SetType*>(this);
|
||||
}
|
||||
|
||||
SetType* Type::AsSetType() {
|
||||
if ( ! IsSet() )
|
||||
BadTag("Type::AsSetType", type_name(tag));
|
||||
return (SetType*)this;
|
||||
return static_cast<SetType*>(this);
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -115,72 +115,72 @@ SetType* Type::AsSetType() {
|
|||
|
||||
const RecordType* Type::AsRecordType() const {
|
||||
CHECK_TYPE_TAG(TYPE_RECORD, "Type::AsRecordType");
|
||||
return (const RecordType*)this;
|
||||
return static_cast<const RecordType*>(this);
|
||||
}
|
||||
|
||||
RecordType* Type::AsRecordType() {
|
||||
CHECK_TYPE_TAG(TYPE_RECORD, "Type::AsRecordType");
|
||||
return (RecordType*)this;
|
||||
return static_cast<RecordType*>(this);
|
||||
}
|
||||
|
||||
const FuncType* Type::AsFuncType() const {
|
||||
CHECK_TYPE_TAG(TYPE_FUNC, "Type::AsFuncType");
|
||||
return (const FuncType*)this;
|
||||
return static_cast<const FuncType*>(this);
|
||||
}
|
||||
|
||||
FuncType* Type::AsFuncType() {
|
||||
CHECK_TYPE_TAG(TYPE_FUNC, "Type::AsFuncType");
|
||||
return (FuncType*)this;
|
||||
return static_cast<FuncType*>(this);
|
||||
}
|
||||
|
||||
const FileType* Type::AsFileType() const {
|
||||
CHECK_TYPE_TAG(TYPE_FILE, "Type::AsFileType");
|
||||
return (const FileType*)this;
|
||||
return static_cast<const FileType*>(this);
|
||||
}
|
||||
|
||||
FileType* Type::AsFileType() {
|
||||
CHECK_TYPE_TAG(TYPE_FILE, "Type::AsFileType");
|
||||
return (FileType*)this;
|
||||
return static_cast<FileType*>(this);
|
||||
}
|
||||
|
||||
const EnumType* Type::AsEnumType() const {
|
||||
CHECK_TYPE_TAG(TYPE_ENUM, "Type::AsEnumType");
|
||||
return (const EnumType*)this;
|
||||
return static_cast<const EnumType*>(this);
|
||||
}
|
||||
|
||||
EnumType* Type::AsEnumType() {
|
||||
CHECK_TYPE_TAG(TYPE_ENUM, "Type::AsEnumType");
|
||||
return (EnumType*)this;
|
||||
return static_cast<EnumType*>(this);
|
||||
}
|
||||
|
||||
const VectorType* Type::AsVectorType() const {
|
||||
CHECK_TYPE_TAG(TYPE_VECTOR, "Type::AsVectorType");
|
||||
return (const VectorType*)this;
|
||||
return static_cast<const VectorType*>(this);
|
||||
}
|
||||
|
||||
VectorType* Type::AsVectorType() {
|
||||
CHECK_TYPE_TAG(TYPE_VECTOR, "Type::AsVectorType");
|
||||
return (VectorType*)this;
|
||||
return static_cast<VectorType*>(this);
|
||||
}
|
||||
|
||||
const OpaqueType* Type::AsOpaqueType() const {
|
||||
CHECK_TYPE_TAG(TYPE_OPAQUE, "Type::AsOpaqueType");
|
||||
return (const OpaqueType*)this;
|
||||
return static_cast<const OpaqueType*>(this);
|
||||
}
|
||||
|
||||
OpaqueType* Type::AsOpaqueType() {
|
||||
CHECK_TYPE_TAG(TYPE_OPAQUE, "Type::AsOpaqueType");
|
||||
return (OpaqueType*)this;
|
||||
return static_cast<OpaqueType*>(this);
|
||||
}
|
||||
|
||||
const TypeType* Type::AsTypeType() const {
|
||||
CHECK_TYPE_TAG(TYPE_TYPE, "Type::AsTypeType");
|
||||
return (const TypeType*)this;
|
||||
return static_cast<const TypeType*>(this);
|
||||
}
|
||||
|
||||
TypeType* Type::AsTypeType() {
|
||||
CHECK_TYPE_TAG(TYPE_TYPE, "Type::AsTypeType");
|
||||
return (TypeType*)this;
|
||||
return static_cast<TypeType*>(this);
|
||||
}
|
||||
|
||||
TypePtr Type::ShallowClone() {
|
||||
|
@ -1249,7 +1249,7 @@ static string container_type_name(const Type* ft) {
|
|||
else
|
||||
s = "table[";
|
||||
|
||||
const auto& tl = ((const IndexType*)ft)->GetIndexTypes();
|
||||
const auto& tl = (static_cast<const IndexType*>(ft))->GetIndexTypes();
|
||||
|
||||
for ( auto i = 0u; i < tl.size(); ++i ) {
|
||||
if ( i > 0 )
|
||||
|
@ -1956,14 +1956,14 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, bool is_init, bool match_
|
|||
return true;
|
||||
|
||||
case TYPE_OPAQUE: {
|
||||
const OpaqueType* ot1 = (const OpaqueType*)t1;
|
||||
const OpaqueType* ot2 = (const OpaqueType*)t2;
|
||||
const OpaqueType* ot1 = static_cast<const OpaqueType*>(t1);
|
||||
const OpaqueType* ot2 = static_cast<const OpaqueType*>(t2);
|
||||
return ot1->Name() == ot2->Name();
|
||||
}
|
||||
|
||||
case TYPE_TABLE: {
|
||||
const IndexType* it1 = (const IndexType*)t1;
|
||||
const IndexType* it2 = (const IndexType*)t2;
|
||||
const IndexType* it1 = static_cast<const IndexType*>(t1);
|
||||
const IndexType* it2 = static_cast<const IndexType*>(t2);
|
||||
|
||||
const auto& tl1 = it1->GetIndices();
|
||||
const auto& tl2 = it2->GetIndices();
|
||||
|
@ -1986,8 +1986,8 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, bool is_init, bool match_
|
|||
}
|
||||
|
||||
case TYPE_FUNC: {
|
||||
const FuncType* ft1 = (const FuncType*)t1;
|
||||
const FuncType* ft2 = (const FuncType*)t2;
|
||||
const FuncType* ft1 = static_cast<const FuncType*>(t1);
|
||||
const FuncType* ft2 = static_cast<const FuncType*>(t2);
|
||||
|
||||
if ( ft1->Flavor() != ft2->Flavor() )
|
||||
return false;
|
||||
|
@ -2001,8 +2001,8 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, bool is_init, bool match_
|
|||
}
|
||||
|
||||
case TYPE_RECORD: {
|
||||
const RecordType* rt1 = (const RecordType*)t1;
|
||||
const RecordType* rt2 = (const RecordType*)t2;
|
||||
const RecordType* rt1 = static_cast<const RecordType*>(t1);
|
||||
const RecordType* rt2 = static_cast<const RecordType*>(t2);
|
||||
|
||||
if ( rt1->NumFields() != rt2->NumFields() )
|
||||
return false;
|
||||
|
@ -2069,8 +2069,8 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, bool is_init, bool match_
|
|||
|
||||
switch ( t1->Tag() ) {
|
||||
case TYPE_TABLE: {
|
||||
const IndexType* it1 = (const IndexType*)t1;
|
||||
const IndexType* it2 = (const IndexType*)t2;
|
||||
const IndexType* it1 = static_cast<const IndexType*>(t1);
|
||||
const IndexType* it2 = static_cast<const IndexType*>(t2);
|
||||
|
||||
const auto& tl1 = it1->GetIndices();
|
||||
const auto& tl2 = it2->GetIndices();
|
||||
|
@ -2093,8 +2093,8 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, bool is_init, bool match_
|
|||
}
|
||||
|
||||
case TYPE_FUNC: {
|
||||
const FuncType* ft1 = (const FuncType*)t1;
|
||||
const FuncType* ft2 = (const FuncType*)t2;
|
||||
const FuncType* ft1 = static_cast<const FuncType*>(t1);
|
||||
const FuncType* ft2 = static_cast<const FuncType*>(t2);
|
||||
|
||||
if ( ! same_type(t1->Yield(), t2->Yield(), is_init, match_record_field_names) )
|
||||
result = false;
|
||||
|
@ -2104,8 +2104,8 @@ bool same_type(const Type& arg_t1, const Type& arg_t2, bool is_init, bool match_
|
|||
}
|
||||
|
||||
case TYPE_RECORD: {
|
||||
const RecordType* rt1 = (const RecordType*)t1;
|
||||
const RecordType* rt2 = (const RecordType*)t2;
|
||||
const RecordType* rt1 = static_cast<const RecordType*>(t1);
|
||||
const RecordType* rt2 = static_cast<const RecordType*>(t2);
|
||||
|
||||
result = true;
|
||||
|
||||
|
@ -2216,7 +2216,7 @@ const Type* flatten_type(const Type* t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
Type* flatten_type(Type* t) { return (Type*)flatten_type((const Type*)t); }
|
||||
Type* flatten_type(Type* t) { return const_cast<Type*>(flatten_type(static_cast<const Type*>(t))); }
|
||||
|
||||
bool is_assignable(TypeTag t) {
|
||||
switch ( t ) {
|
||||
|
@ -2303,8 +2303,8 @@ TypePtr merge_enum_types(const Type* t1, const Type* t2) {
|
|||
}
|
||||
|
||||
TypePtr merge_table_types(const Type* t1, const Type* t2) {
|
||||
const IndexType* it1 = (const IndexType*)t1;
|
||||
const IndexType* it2 = (const IndexType*)t2;
|
||||
const IndexType* it1 = static_cast<const IndexType*>(t1);
|
||||
const IndexType* it2 = static_cast<const IndexType*>(t2);
|
||||
|
||||
const auto& tl1 = it1->GetIndexTypes();
|
||||
const auto& tl2 = it2->GetIndexTypes();
|
||||
|
@ -2349,8 +2349,8 @@ TypePtr merge_func_types(const Type* t1, const Type* t2) {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const FuncType* ft1 = (const FuncType*)t1;
|
||||
const FuncType* ft2 = (const FuncType*)t1;
|
||||
const FuncType* ft1 = static_cast<const FuncType*>(t1);
|
||||
const FuncType* ft2 = static_cast<const FuncType*>(t1);
|
||||
auto args = cast_intrusive<RecordType>(merge_types(ft1->Params(), ft2->Params()));
|
||||
auto yield = t1->Yield() ? merge_types(t1->Yield(), t2->Yield()) : nullptr;
|
||||
|
||||
|
@ -2358,8 +2358,8 @@ TypePtr merge_func_types(const Type* t1, const Type* t2) {
|
|||
}
|
||||
|
||||
TypePtr merge_record_types(const Type* t1, const Type* t2) {
|
||||
const RecordType* rt1 = (const RecordType*)t1;
|
||||
const RecordType* rt2 = (const RecordType*)t2;
|
||||
const RecordType* rt1 = static_cast<const RecordType*>(t1);
|
||||
const RecordType* rt2 = static_cast<const RecordType*>(t2);
|
||||
|
||||
// We allow the records to have different numbers of fields.
|
||||
// We first go through all of the fields in rt1, and then we
|
||||
|
|
12
src/Val.cc
12
src/Val.cc
|
@ -62,13 +62,13 @@ Val::~Val() {
|
|||
#define CONVERTER(tag, ctype, name) \
|
||||
ctype name() { \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONVERTER", type_name) \
|
||||
return (ctype)(this); \
|
||||
return static_cast<ctype>(this); \
|
||||
}
|
||||
|
||||
#define CONST_CONVERTER(tag, ctype, name) \
|
||||
const ctype name() const { \
|
||||
CHECK_TAG(type->Tag(), tag, "Val::CONVERTER", type_name) \
|
||||
return (const ctype)(this); \
|
||||
return static_cast<const ctype>(this); \
|
||||
}
|
||||
|
||||
#define CONVERTERS(tag, ctype, name) \
|
||||
|
@ -1415,7 +1415,7 @@ RE_Matcher* ListVal::BuildRE() const {
|
|||
|
||||
RE_Matcher* re = new RE_Matcher();
|
||||
for ( const auto& val : vals ) {
|
||||
const char* vs = (const char*)(val->AsString()->Bytes());
|
||||
const char* vs = reinterpret_cast<const char*>(val->AsString()->Bytes());
|
||||
re->AddPat(vs);
|
||||
}
|
||||
|
||||
|
@ -1521,7 +1521,7 @@ void TableValTimer::Dispatch(double t, bool is_expire) {
|
|||
}
|
||||
|
||||
static void table_entry_val_delete_func(void* val) {
|
||||
TableEntryVal* tv = (TableEntryVal*)val;
|
||||
TableEntryVal* tv = reinterpret_cast<TableEntryVal*>(val);
|
||||
delete tv;
|
||||
}
|
||||
|
||||
|
@ -2093,7 +2093,7 @@ const detail::AttrPtr& TableVal::DefaultAttr() const {
|
|||
|
||||
const ValPtr& TableVal::Find(const ValPtr& index) {
|
||||
if ( subnets ) {
|
||||
TableEntryVal* v = (TableEntryVal*)subnets->Lookup(index.get());
|
||||
TableEntryVal* v = reinterpret_cast<TableEntryVal*>(subnets->Lookup(index.get()));
|
||||
if ( v ) {
|
||||
if ( attrs && attrs->Find(detail::ATTR_EXPIRE_READ) )
|
||||
v->SetExpireAccess(run_state::network_time);
|
||||
|
@ -2215,7 +2215,7 @@ bool TableVal::UpdateTimestamp(Val* index) {
|
|||
TableEntryVal* v;
|
||||
|
||||
if ( subnets )
|
||||
v = (TableEntryVal*)subnets->Lookup(index);
|
||||
v = reinterpret_cast<TableEntryVal*>(subnets->Lookup(index));
|
||||
else {
|
||||
auto k = MakeHashKey(*index);
|
||||
|
||||
|
|
|
@ -172,14 +172,16 @@ std::pair<const char*, size_t> String::CheckStringWithSize() const {
|
|||
return {result, std::size(result) - 1};
|
||||
}
|
||||
|
||||
return {(const char*)b, n};
|
||||
return {reinterpret_cast<const char*>(b), n};
|
||||
}
|
||||
|
||||
const char* String::CheckString() const { return CheckStringWithSize().first; }
|
||||
|
||||
std::string String::ToStdString() const { return {(char*)Bytes(), static_cast<size_t>(Len())}; }
|
||||
std::string String::ToStdString() const { return {reinterpret_cast<char*>(Bytes()), static_cast<size_t>(Len())}; }
|
||||
|
||||
std::string_view String::ToStdStringView() const { return {(char*)Bytes(), static_cast<size_t>(Len())}; }
|
||||
std::string_view String::ToStdStringView() const {
|
||||
return {reinterpret_cast<char*>(Bytes()), static_cast<size_t>(Len())};
|
||||
}
|
||||
|
||||
char* String::Render(int format, int* len) const {
|
||||
// Maximum character expansion is as \xHH, so a factor of 4.
|
||||
|
@ -254,7 +256,7 @@ std::istream& String::Read(std::istream& is, int format) {
|
|||
is.read(buf, len);
|
||||
buf[len] = '\0'; // NUL-terminate just for safety
|
||||
|
||||
Adopt((u_char*)buf, len + 1);
|
||||
Adopt(reinterpret_cast<u_char*>(buf), len + 1);
|
||||
}
|
||||
else {
|
||||
std::string str;
|
||||
|
@ -378,7 +380,7 @@ String* concatenate(std::vector<data_chunk_t>& v) {
|
|||
|
||||
*b = '\0';
|
||||
|
||||
return new String(true, (byte_vec)data, len);
|
||||
return new String(true, reinterpret_cast<byte_vec>(data), len);
|
||||
}
|
||||
|
||||
String* concatenate(String::CVec& v) {
|
||||
|
@ -397,7 +399,7 @@ String* concatenate(String::CVec& v) {
|
|||
}
|
||||
*b = '\0';
|
||||
|
||||
return new String(true, (byte_vec)data, len);
|
||||
return new String(true, reinterpret_cast<byte_vec>(data), len);
|
||||
}
|
||||
|
||||
String* concatenate(String::Vec& v) {
|
||||
|
@ -458,7 +460,7 @@ TEST_CASE("construction") {
|
|||
zeek::String s9{false, text4, 6};
|
||||
CHECK_EQ(std::string(s9.CheckString()), "<string-with-NUL>");
|
||||
|
||||
zeek::byte_vec text5 = (zeek::byte_vec)malloc(7);
|
||||
zeek::byte_vec text5 = reinterpret_cast<zeek::byte_vec>(malloc(7));
|
||||
memcpy(text5, text.c_str(), 7);
|
||||
zeek::String s10{true, text5, 6};
|
||||
s10.SetUseFreeToDelete(1);
|
||||
|
|
|
@ -583,13 +583,13 @@ SupportAnalyzer* Analyzer::FirstSupportAnalyzer(bool orig) {
|
|||
|
||||
void Analyzer::DeliverPacket(int len, const u_char* data, bool is_orig, uint64_t seq, const IP_Hdr* ip, int caplen) {
|
||||
DBG_LOG(DBG_ANALYZER, "%s DeliverPacket(%d, %s, %" PRIu64 ", %p, %d) [%s%s]", fmt_analyzer(this).c_str(), len,
|
||||
is_orig ? "T" : "F", seq, ip, caplen, util::fmt_bytes((const char*)data, min(40, len)),
|
||||
is_orig ? "T" : "F", seq, ip, caplen, util::fmt_bytes(reinterpret_cast<const char*>(data), min(40, len)),
|
||||
len > 40 ? "..." : "");
|
||||
}
|
||||
|
||||
void Analyzer::DeliverStream(int len, const u_char* data, bool is_orig) {
|
||||
DBG_LOG(DBG_ANALYZER, "%s DeliverStream(%d, %s) [%s%s]", fmt_analyzer(this).c_str(), len, is_orig ? "T" : "F",
|
||||
util::fmt_bytes((const char*)data, min(40, len)), len > 40 ? "..." : "");
|
||||
util::fmt_bytes(reinterpret_cast<const char*>(data), min(40, len)), len > 40 ? "..." : "");
|
||||
}
|
||||
|
||||
void Analyzer::Undelivered(uint64_t seq, int len, bool is_orig) {
|
||||
|
|
|
@ -418,7 +418,7 @@ void BitTorrentTracker_Analyzer::ResponseBenc(int name_len, char* name, detail::
|
|||
// addresses in network order but PortVal's
|
||||
// take ports in host order. BitTorrent specifies
|
||||
// that both are in network order here.
|
||||
uint32_t ad = extract_uint32((u_char*)value);
|
||||
uint32_t ad = extract_uint32(reinterpret_cast<u_char*>(value));
|
||||
uint16_t pt = ntohs((value[4] << 8) | value[5]);
|
||||
|
||||
auto peer = make_intrusive<RecordVal>(bittorrent_peer);
|
||||
|
|
|
@ -88,9 +88,9 @@ refine connection DCE_RPC_Conn += {
|
|||
// Remove the null from the end of the string if it's there.
|
||||
if ( ${bind.sec_addr}.length() > 0 &&
|
||||
*(${bind.sec_addr}.begin() + ${bind.sec_addr}.length()) == 0 )
|
||||
sec_addr = zeek::make_intrusive<zeek::StringVal>(${bind.sec_addr}.length()-1, (const char*) ${bind.sec_addr}.begin());
|
||||
sec_addr = zeek::make_intrusive<zeek::StringVal>(${bind.sec_addr}.length()-1, reinterpret_cast<const char*>(${bind.sec_addr}.begin()));
|
||||
else
|
||||
sec_addr = zeek::make_intrusive<zeek::StringVal>(${bind.sec_addr}.length(), (const char*) ${bind.sec_addr}.begin());
|
||||
sec_addr = zeek::make_intrusive<zeek::StringVal>(${bind.sec_addr}.length(), reinterpret_cast<const char*>(${bind.sec_addr}.begin()));
|
||||
|
||||
zeek::BifEvent::enqueue_dce_rpc_bind_ack(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
|
|
|
@ -631,7 +631,7 @@ refine flow DHCP_Flow += {
|
|||
|
||||
if ( ${v.client_id.hwtype} == 0 )
|
||||
sv = zeek::make_intrusive<zeek::StringVal>(${v.client_id.hwaddr}.length(),
|
||||
(const char*)${v.client_id.hwaddr}.begin());
|
||||
reinterpret_cast<const char*>(${v.client_id.hwaddr}.begin()));
|
||||
else
|
||||
sv = zeek::make_intrusive<zeek::StringVal>(zeek::fmt_mac(${v.client_id.hwaddr}.begin(),
|
||||
${v.client_id.hwaddr}.length()));
|
||||
|
|
|
@ -69,7 +69,7 @@ void DNS_Interpreter::ParseMessage(const u_char* data, int len, int is_query) {
|
|||
// The flags section may be different between the different opcodes, but the
|
||||
// opcode is always in the same location. Parse out just that part of it here
|
||||
// even though it will probably be reparsed later.
|
||||
auto* hdr = (detail::DNS_RawMsgHdr*)data;
|
||||
auto* hdr = reinterpret_cast<const detail::DNS_RawMsgHdr*>(data);
|
||||
auto flags = ntohs(hdr->flags);
|
||||
auto opcode = static_cast<uint16_t>((flags & 0x7800) >> 11);
|
||||
|
||||
|
@ -80,7 +80,7 @@ void DNS_Interpreter::ParseMessage(const u_char* data, int len, int is_query) {
|
|||
return;
|
||||
}
|
||||
|
||||
detail::DNS_MsgInfo msg(hdr, is_query);
|
||||
detail::DNS_MsgInfo msg(const_cast<detail::DNS_RawMsgHdr*>(hdr), is_query);
|
||||
|
||||
if ( first_message && msg.QR && is_query == 1 ) {
|
||||
is_query = 0;
|
||||
|
@ -2130,12 +2130,12 @@ void Contents_DNS::ProcessChunk(int& len, const u_char*& data, bool orig) {
|
|||
if ( msg_buf ) {
|
||||
if ( buf_len < msg_size ) {
|
||||
buf_len = msg_size;
|
||||
msg_buf = (u_char*)util::safe_realloc((void*)msg_buf, buf_len);
|
||||
msg_buf = reinterpret_cast<u_char*>(util::safe_realloc((void*)msg_buf, buf_len));
|
||||
}
|
||||
}
|
||||
else {
|
||||
buf_len = msg_size;
|
||||
msg_buf = (u_char*)util::safe_malloc(buf_len);
|
||||
msg_buf = reinterpret_cast<u_char*>(util::safe_malloc(buf_len));
|
||||
}
|
||||
|
||||
++data;
|
||||
|
|
|
@ -19,7 +19,7 @@ void File_Analyzer::DeliverStream(int len, const u_char* data, bool orig) {
|
|||
int n = std::min(len, BUFFER_SIZE - buffer_len);
|
||||
|
||||
if ( n ) {
|
||||
memcpy(buffer + buffer_len, (const char*)data, n);
|
||||
memcpy(buffer + buffer_len, reinterpret_cast<const char*>(data), n);
|
||||
buffer_len += n;
|
||||
|
||||
if ( buffer_len == BUFFER_SIZE )
|
||||
|
|
|
@ -72,7 +72,7 @@ void FTP_Analyzer::DeliverStream(int length, const u_char* data, bool orig) {
|
|||
return;
|
||||
|
||||
// const char* orig_line = line;
|
||||
const char* line = (const char*)data;
|
||||
const char* line = reinterpret_cast<const char*>(data);
|
||||
const char* end_of_line = line + length;
|
||||
|
||||
if ( length == 0 )
|
||||
|
@ -120,11 +120,12 @@ void FTP_Analyzer::DeliverStream(int length, const u_char* data, bool orig) {
|
|||
f = ftp_request;
|
||||
AnalyzerConfirmation();
|
||||
|
||||
if ( strncmp((const char*)cmd_str->Bytes(), "AUTH", cmd_len) == 0 )
|
||||
if ( strncmp(reinterpret_cast<const char*>(cmd_str->Bytes()), "AUTH", cmd_len) == 0 )
|
||||
auth_requested = std::string(line, end_of_line - line);
|
||||
|
||||
if ( detail::rule_matcher )
|
||||
Conn()->Match(zeek::detail::Rule::FTP, (const u_char*)cmd, end_of_line - cmd, true, true, true, true);
|
||||
Conn()->Match(zeek::detail::Rule::FTP, reinterpret_cast<const u_char*>(cmd), end_of_line - cmd, true, true,
|
||||
true, true);
|
||||
}
|
||||
else {
|
||||
uint32_t reply_code = get_reply_code(length, line);
|
||||
|
@ -147,11 +148,11 @@ void FTP_Analyzer::DeliverStream(int length, const u_char* data, bool orig) {
|
|||
cont_resp = 0;
|
||||
|
||||
if ( reply_code == 0 ) {
|
||||
AnalyzerViolation("non-numeric reply code", (const char*)data, length);
|
||||
AnalyzerViolation("non-numeric reply code", reinterpret_cast<const char*>(data), length);
|
||||
return;
|
||||
}
|
||||
else if ( reply_code < 100 ) {
|
||||
AnalyzerViolation("invalid reply code", (const char*)data, length);
|
||||
AnalyzerViolation("invalid reply code", reinterpret_cast<const char*>(data), length);
|
||||
return;
|
||||
}
|
||||
else if ( length > 3 && line[3] == '-' ) { // a continued reply
|
||||
|
@ -162,7 +163,7 @@ void FTP_Analyzer::DeliverStream(int length, const u_char* data, bool orig) {
|
|||
else if ( length > 3 && line[3] != ' ' ) {
|
||||
// This is a proper reply code, but there's no space after
|
||||
// the reply code even though the line is long enough.
|
||||
AnalyzerViolation("invalid reply line", (const char*)data, length);
|
||||
AnalyzerViolation("invalid reply line", reinterpret_cast<const char*>(data), length);
|
||||
return;
|
||||
}
|
||||
else { // a self-contained reply
|
||||
|
@ -219,7 +220,7 @@ void FTP_ADAT_Analyzer::DeliverStream(int len, const u_char* data, bool orig) {
|
|||
}
|
||||
|
||||
bool done = false;
|
||||
const char* line = (const char*)data;
|
||||
const char* line = reinterpret_cast<const char*>(data);
|
||||
const char* end_of_line = line + len;
|
||||
|
||||
String* decoded_adat = nullptr;
|
||||
|
@ -255,7 +256,8 @@ void FTP_ADAT_Analyzer::DeliverStream(int len, const u_char* data, bool orig) {
|
|||
// record from the first byte (content type of 0x16) and
|
||||
// that the fourth and fifth bytes indicating the length of
|
||||
// the record match the length of the decoded data.
|
||||
if ( msg_len < 5 || msg[0] != 0x16 || msg_len - 5 != ntohs(*((uint16_t*)(msg + 3))) ) {
|
||||
if ( msg_len < 5 || msg[0] != 0x16 ||
|
||||
msg_len - 5 != ntohs(*reinterpret_cast<const uint16_t*>(msg + 3)) ) {
|
||||
// Doesn't look like TLS/SSL, so done analyzing.
|
||||
done = true;
|
||||
delete decoded_adat;
|
||||
|
|
|
@ -167,7 +167,7 @@ class HTTP_Entity::UncompressedOutput : public analyzer::OutputHandler {
|
|||
public:
|
||||
UncompressedOutput(HTTP_Entity* e) { entity = e; }
|
||||
void DeliverStream(int len, const u_char* data, bool orig) override {
|
||||
entity->DeliverBodyClear(len, (char*)data, false);
|
||||
entity->DeliverBodyClear(len, reinterpret_cast<const char*>(data), false);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -185,7 +185,7 @@ void HTTP_Entity::DeliverBody(int len, const char* data, bool trailing_CRLF) {
|
|||
zip->SetOutputHandler(new UncompressedOutput(this));
|
||||
}
|
||||
|
||||
zip->NextStream(len, (const u_char*)data, false);
|
||||
zip->NextStream(len, reinterpret_cast<const u_char*>(data), false);
|
||||
}
|
||||
else
|
||||
DeliverBodyClear(len, data, trailing_CRLF);
|
||||
|
@ -204,11 +204,11 @@ void HTTP_Entity::DeliverBodyClear(int len, const char* data, bool trailing_CRLF
|
|||
zeek::detail::Rule::PatternType rule =
|
||||
http_message->IsOrig() ? zeek::detail::Rule::HTTP_REQUEST_BODY : zeek::detail::Rule::HTTP_REPLY_BODY;
|
||||
|
||||
http_message->MyHTTP_Analyzer()->Conn()->Match(rule, (const u_char*)data, len, http_message->IsOrig(), new_data,
|
||||
false, new_data);
|
||||
http_message->MyHTTP_Analyzer()->Conn()->Match(rule, reinterpret_cast<const u_char*>(data), len,
|
||||
http_message->IsOrig(), new_data, false, new_data);
|
||||
|
||||
// FIXME: buffer data for forwarding (matcher might match later).
|
||||
http_message->MyHTTP_Analyzer()->ForwardStream(len, (const u_char*)data, http_message->IsOrig());
|
||||
http_message->MyHTTP_Analyzer()->ForwardStream(len, reinterpret_cast<const u_char*>(data), http_message->IsOrig());
|
||||
}
|
||||
|
||||
// Returns 1 if the undelivered bytes are completely within the body,
|
||||
|
@ -599,7 +599,7 @@ void HTTP_Message::BeginEntity(analyzer::mime::MIME_Entity* entity) {
|
|||
if ( DEBUG_http )
|
||||
DEBUG_MSG("%.6f: begin entity (%d)\n", run_state::network_time, is_orig);
|
||||
|
||||
current_entity = (HTTP_Entity*)entity;
|
||||
current_entity = static_cast<HTTP_Entity*>(entity);
|
||||
|
||||
if ( http_begin_entity )
|
||||
analyzer->EnqueueConnEvent(http_begin_entity, analyzer->ConnVal(), val_mgr->Bool(is_orig));
|
||||
|
@ -610,14 +610,14 @@ void HTTP_Message::EndEntity(analyzer::mime::MIME_Entity* entity) {
|
|||
DEBUG_MSG("%.6f: end entity (%d)\n", run_state::network_time, is_orig);
|
||||
|
||||
if ( entity == top_level ) {
|
||||
body_length += ((HTTP_Entity*)entity)->BodyLength();
|
||||
header_length += ((HTTP_Entity*)entity)->HeaderLength();
|
||||
body_length += (static_cast<HTTP_Entity*>(entity))->BodyLength();
|
||||
header_length += (static_cast<HTTP_Entity*>(entity))->HeaderLength();
|
||||
}
|
||||
|
||||
if ( http_end_entity )
|
||||
analyzer->EnqueueConnEvent(http_end_entity, analyzer->ConnVal(), val_mgr->Bool(is_orig));
|
||||
|
||||
current_entity = (HTTP_Entity*)entity->Parent();
|
||||
current_entity = static_cast<HTTP_Entity*>(entity->Parent());
|
||||
|
||||
if ( entity->Parent() && entity->Parent()->MIMEContentType() == analyzer::mime::CONTENT_TYPE_MULTIPART ) {
|
||||
content_line->SuppressWeirds(false);
|
||||
|
@ -1248,7 +1248,8 @@ bool HTTP_Analyzer::ParseRequest(const char* line, const char* end_of_line) {
|
|||
// NormalizeURI(line, end_of_uri);
|
||||
|
||||
request_URI = make_intrusive<StringVal>(end_of_uri - line, line);
|
||||
unescaped_URI = make_intrusive<StringVal>(unescape_URI((const u_char*)line, (const u_char*)end_of_uri, this));
|
||||
unescaped_URI = make_intrusive<StringVal>(
|
||||
unescape_URI(reinterpret_cast<const u_char*>(line), reinterpret_cast<const u_char*>(end_of_uri), this));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -1305,7 +1306,7 @@ StringValPtr HTTP_Analyzer::TruncateURI(const StringValPtr& uri) {
|
|||
void HTTP_Analyzer::HTTP_Request() {
|
||||
AnalyzerConfirmation();
|
||||
|
||||
const char* method = (const char*)request_method->AsString()->Bytes();
|
||||
const char* method = reinterpret_cast<const char*>(request_method->AsString()->Bytes());
|
||||
int method_len = request_method->AsString()->Len();
|
||||
|
||||
if ( strncasecmp(method, "CONNECT", method_len) == 0 )
|
||||
|
@ -1544,7 +1545,7 @@ int HTTP_Analyzer::ExpectReplyMessageBody() {
|
|||
|
||||
const String* method = UnansweredRequestMethod();
|
||||
|
||||
if ( method && strncasecmp((const char*)(method->Bytes()), "HEAD", method->Len()) == 0 )
|
||||
if ( method && strncasecmp(reinterpret_cast<const char*>(method->Bytes()), "HEAD", method->Len()) == 0 )
|
||||
return HTTP_BODY_NOT_EXPECTED;
|
||||
|
||||
if ( (reply_code >= 100 && reply_code < 200) || reply_code == 204 || reply_code == 304 )
|
||||
|
@ -1580,9 +1581,10 @@ void HTTP_Analyzer::HTTP_Header(bool is_orig, analyzer::mime::MIME_Header* h) {
|
|||
data_chunk_t hd_name = h->get_name();
|
||||
data_chunk_t hd_value = h->get_value();
|
||||
|
||||
Conn()->Match(rule, (const u_char*)hd_name.data, hd_name.length, is_orig, true, false, true);
|
||||
Conn()->Match(rule, (const u_char*)": ", 2, is_orig, false, false, false);
|
||||
Conn()->Match(rule, (const u_char*)hd_value.data, hd_value.length, is_orig, false, true, false);
|
||||
Conn()->Match(rule, reinterpret_cast<const u_char*>(hd_name.data), hd_name.length, is_orig, true, false, true);
|
||||
Conn()->Match(rule, reinterpret_cast<const u_char*>(": "), 2, is_orig, false, false, false);
|
||||
Conn()->Match(rule, reinterpret_cast<const u_char*>(hd_value.data), hd_value.length, is_orig, false, true,
|
||||
false);
|
||||
|
||||
if ( DEBUG_http )
|
||||
DEBUG_MSG("%.6f http_header\n", run_state::network_time);
|
||||
|
|
|
@ -39,7 +39,7 @@ void Ident_Analyzer::Done() {
|
|||
void Ident_Analyzer::DeliverStream(int length, const u_char* data, bool is_orig) {
|
||||
analyzer::tcp::TCP_ApplicationAnalyzer::DeliverStream(length, data, is_orig);
|
||||
|
||||
const char* line = (const char*)data;
|
||||
const char* line = reinterpret_cast<const char*>(data);
|
||||
const char* orig_line = line;
|
||||
const char* end_of_line = line + length;
|
||||
|
||||
|
@ -71,7 +71,7 @@ void Ident_Analyzer::DeliverStream(int length, const u_char* data, bool is_orig)
|
|||
}
|
||||
|
||||
if ( line != end_of_line ) {
|
||||
String s((const u_char*)orig_line, length, true);
|
||||
String s(reinterpret_cast<const u_char*>(orig_line), length, true);
|
||||
Weird("ident_request_addendum", s.CheckString());
|
||||
}
|
||||
|
||||
|
@ -149,7 +149,7 @@ void Ident_Analyzer::DeliverStream(int length, const u_char* data, bool is_orig)
|
|||
for ( ; sys_end > sys_type && isspace(*sys_end); --sys_end )
|
||||
;
|
||||
|
||||
String* sys_type_s = new String((const u_char*)sys_type, sys_end - sys_type + 1, true);
|
||||
String* sys_type_s = new String(reinterpret_cast<const u_char*>(sys_type), sys_end - sys_type + 1, true);
|
||||
|
||||
line = util::skip_whitespace(colon + 1, end_of_line);
|
||||
|
||||
|
@ -206,13 +206,13 @@ const char* Ident_Analyzer::ParsePort(const char* line, const char* end_of_line,
|
|||
}
|
||||
|
||||
void Ident_Analyzer::BadRequest(int length, const char* line) {
|
||||
String s((const u_char*)line, length, true);
|
||||
String s(reinterpret_cast<const u_char*>(line), length, true);
|
||||
Weird("bad_ident_request", s.CheckString());
|
||||
}
|
||||
|
||||
void Ident_Analyzer::BadReply(int length, const char* line) {
|
||||
if ( ! did_bad_reply ) {
|
||||
String s((const u_char*)line, length, true);
|
||||
String s(reinterpret_cast<const u_char*>(line), length, true);
|
||||
Weird("bad_ident_reply", s.CheckString());
|
||||
did_bad_reply = true;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ refine connection IMAP_Conn += {
|
|||
for ( unsigned int i = 0; i< capabilities->size(); i++ )
|
||||
{
|
||||
const bytestring& capability = (*capabilities)[i]->cap();
|
||||
capv->Assign(i, zeek::make_intrusive<zeek::StringVal>(capability.length(), (const char*)capability.data()));
|
||||
capv->Assign(i, zeek::make_intrusive<zeek::StringVal>(capability.length(), reinterpret_cast<const char*>(capability.data())));
|
||||
}
|
||||
|
||||
zeek::BifEvent::enqueue_imap_capabilities(zeek_analyzer(), zeek_analyzer()->Conn(), std::move(capv));
|
||||
|
|
|
@ -69,7 +69,7 @@ void IRC_Analyzer::DeliverStream(int length, const u_char* line, bool orig) {
|
|||
return;
|
||||
}
|
||||
|
||||
string myline = string((const char*)line, length);
|
||||
string myline = string(reinterpret_cast<const char*>(line), length);
|
||||
SkipLeadingWhitespace(myline);
|
||||
|
||||
if ( myline.length() < 3 ) {
|
||||
|
|
|
@ -23,7 +23,7 @@ zeek::ValPtr GetTimeFromAsn1(zeek::StringVal* atime, int64 usecs)
|
|||
char* pBuffer = lBuffer;
|
||||
|
||||
size_t lTimeLength = atime->Len();
|
||||
char * pString = (char *) atime->Bytes();
|
||||
const char* pString = reinterpret_cast<const char*>(atime->Bytes());
|
||||
|
||||
if ( lTimeLength != 15 && lTimeLength != 17 )
|
||||
return nullptr;
|
||||
|
|
|
@ -20,9 +20,9 @@ zeek::ValPtr GetStringFromPrincipalName(const KRB_Principal_Name* pname)
|
|||
if ( pname->data()->size() == 1 )
|
||||
return to_stringval(pname->data()[0][0]->encoding()->content());
|
||||
if ( pname->data()->size() == 2 )
|
||||
return zeek::make_intrusive<zeek::StringVal>(zeek::util::fmt("%s/%s", (char *) pname->data()[0][0]->encoding()->content().begin(), (char *)pname->data()[0][1]->encoding()->content().begin()));
|
||||
return zeek::make_intrusive<zeek::StringVal>(zeek::util::fmt("%s/%s", reinterpret_cast<const char *> (pname->data()[0][0]->encoding()->content().begin()), reinterpret_cast<const char *>(pname->data()[0][1]->encoding()->content().begin())));
|
||||
if ( pname->data()->size() == 3 ) // if the name-string has a third value, this will just append it, else this will return unknown as the principal name
|
||||
return zeek::make_intrusive<zeek::StringVal>(zeek::util::fmt("%s/%s/%s", (char *) pname->data()[0][0]->encoding()->content().begin(), (char *)pname->data()[0][1]->encoding()->content().begin(), (char *)pname->data()[0][2]->encoding()->content().begin()));
|
||||
return zeek::make_intrusive<zeek::StringVal>(zeek::util::fmt("%s/%s/%s", reinterpret_cast<const char *>(pname->data()[0][0]->encoding()->content().begin()), reinterpret_cast<const char *>(pname->data()[0][1]->encoding()->content().begin()), reinterpret_cast<const char *>(pname->data()[0][2]->encoding()->content().begin())));
|
||||
|
||||
return zeek::make_intrusive<zeek::StringVal>("unknown");
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ void Login_Analyzer::AuthenticationDialog(bool orig, char* line) {
|
|||
// VMS repeats the username, not the last line
|
||||
// typed (which presumably is the password).
|
||||
if ( username ) {
|
||||
line = (char*)username->AsString()->Bytes();
|
||||
line = reinterpret_cast<char*>(username->AsString()->Bytes());
|
||||
if ( strstr(line, VMS_REPEAT_SEQ) )
|
||||
Confused("username_with_embedded_repeat", line);
|
||||
else
|
||||
|
@ -287,7 +287,7 @@ void Login_Analyzer::SetEnv(bool orig, char* name, char* val) {
|
|||
if ( username ) {
|
||||
const String* u = username->AsString();
|
||||
const byte_vec ub = u->Bytes();
|
||||
const char* us = (const char*)ub;
|
||||
const char* us = reinterpret_cast<const char*>(ub);
|
||||
if ( ! util::streq(val, us) )
|
||||
Confused("multiple_USERs", val);
|
||||
Unref(username);
|
||||
|
|
|
@ -138,7 +138,7 @@ void TelnetEncryptOption::RecvSubOption(u_char* data, int len) {
|
|||
++did_encrypt_request;
|
||||
|
||||
else if ( opt == ENCRYPT_STARTING_TO_ENCRYPT ) {
|
||||
TelnetEncryptOption* peer = (TelnetEncryptOption*)endp->FindPeerOption(code);
|
||||
TelnetEncryptOption* peer = static_cast<TelnetEncryptOption*>(endp->FindPeerOption(code));
|
||||
|
||||
if ( ! peer ) {
|
||||
reporter->AnalyzerError(endp, "option peer missing in TelnetEncryptOption::RecvSubOption");
|
||||
|
@ -172,7 +172,7 @@ void TelnetAuthenticateOption::RecvSubOption(u_char* data, int len) {
|
|||
|
||||
switch ( data[0] ) {
|
||||
case HERE_IS_AUTHENTICATION: {
|
||||
TelnetAuthenticateOption* peer = (TelnetAuthenticateOption*)endp->FindPeerOption(code);
|
||||
TelnetAuthenticateOption* peer = static_cast<TelnetAuthenticateOption*>(endp->FindPeerOption(code));
|
||||
|
||||
if ( ! peer ) {
|
||||
reporter->AnalyzerError(endp, "option peer missing in TelnetAuthenticateOption::RecvSubOption");
|
||||
|
@ -203,7 +203,7 @@ void TelnetAuthenticateOption::RecvSubOption(u_char* data, int len) {
|
|||
|
||||
case AUTHENTICATION_NAME: {
|
||||
char* auth_name = new char[len];
|
||||
util::safe_strncpy(auth_name, (char*)data + 1, len);
|
||||
util::safe_strncpy(auth_name, reinterpret_cast<char*>(data) + 1, len);
|
||||
endp->SetAuthName(auth_name);
|
||||
} break;
|
||||
|
||||
|
@ -570,7 +570,7 @@ void NVT_Analyzer::ScanOption(int& len, const u_char*& data) {
|
|||
int opt_start = IAC_pos + 2;
|
||||
int opt_stop = offset - 1;
|
||||
int opt_len = opt_stop - opt_start;
|
||||
SawSubOption((const char*)&buf[opt_start], opt_len);
|
||||
SawSubOption(reinterpret_cast<const char*>(&buf[opt_start]), opt_len);
|
||||
|
||||
// Delete suboption.
|
||||
offset = IAC_pos;
|
||||
|
@ -612,7 +612,7 @@ void NVT_Analyzer::SawSubOption(const char* subopt, int len) {
|
|||
|
||||
TelnetOption* opt = FindOption(subcode);
|
||||
if ( opt )
|
||||
opt->RecvSubOption((u_char*)subopt, len);
|
||||
opt->RecvSubOption(const_cast<u_char*>(reinterpret_cast<const u_char*>(subopt)), len);
|
||||
}
|
||||
|
||||
void NVT_Analyzer::BadOptionTermination(unsigned int /* code */) { Event(bad_option_termination); }
|
||||
|
|
|
@ -62,12 +62,12 @@ void Contents_Rsh_Analyzer::DoDeliver(int len, const u_char* data) {
|
|||
buf[offset++] = c;
|
||||
if ( c == '\0' ) {
|
||||
if ( state == RSH_CLIENT_USER_NAME ) {
|
||||
analyzer->ClientUserName((const char*)buf);
|
||||
analyzer->ClientUserName(reinterpret_cast<const char*>(buf));
|
||||
state = RSH_SERVER_USER_NAME;
|
||||
}
|
||||
|
||||
else if ( state == RSH_SERVER_USER_NAME && offset > 1 ) {
|
||||
analyzer->ServerUserName((const char*)buf);
|
||||
analyzer->ServerUserName(reinterpret_cast<const char*>(buf));
|
||||
save_state = state;
|
||||
state = RSH_LINE_MODE;
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ void Rsh_Analyzer::DeliverStream(int len, const u_char* data, bool orig) {
|
|||
|
||||
Args vl;
|
||||
vl.reserve(4 + orig);
|
||||
const char* line = (const char*)data;
|
||||
const char* line = reinterpret_cast<const char*>(data);
|
||||
line = util::skip_whitespace(line);
|
||||
vl.emplace_back(ConnVal());
|
||||
|
||||
|
|
|
@ -57,17 +57,17 @@ void Contents_Rlogin_Analyzer::DoDeliver(int len, const u_char* data) {
|
|||
buf[offset++] = c;
|
||||
if ( c == '\0' ) {
|
||||
if ( state == RLOGIN_CLIENT_USER_NAME ) {
|
||||
analyzer->ClientUserName((const char*)buf);
|
||||
analyzer->ClientUserName(reinterpret_cast<const char*>(buf));
|
||||
state = RLOGIN_SERVER_USER_NAME;
|
||||
}
|
||||
|
||||
else if ( state == RLOGIN_SERVER_USER_NAME ) {
|
||||
analyzer->ServerUserName((const char*)buf);
|
||||
analyzer->ServerUserName(reinterpret_cast<const char*>(buf));
|
||||
state = RLOGIN_TERMINAL_TYPE;
|
||||
}
|
||||
|
||||
else if ( state == RLOGIN_TERMINAL_TYPE ) {
|
||||
analyzer->TerminalType((const char*)buf);
|
||||
analyzer->TerminalType(reinterpret_cast<const char*>(buf));
|
||||
state = RLOGIN_LINE_MODE;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ StringValPtr to_string_val(const data_chunk_t buf) { return to_string_val(buf.le
|
|||
static data_chunk_t get_data_chunk(String* s) {
|
||||
data_chunk_t b;
|
||||
b.length = s->Len();
|
||||
b.data = (const char*)s->Bytes();
|
||||
b.data = reinterpret_cast<const char*>(s->Bytes());
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -343,7 +343,7 @@ int MIME_get_value(int len, const char* data, String*& buf, bool is_boundary) {
|
|||
if ( end < 0 )
|
||||
return -1;
|
||||
|
||||
buf = new String((const u_char*)str.data, str.length, true);
|
||||
buf = new String(reinterpret_cast<const u_char*>(str.data), str.length, true);
|
||||
return offset + end;
|
||||
}
|
||||
}
|
||||
|
@ -368,7 +368,7 @@ String* MIME_decode_quoted_pairs(data_chunk_t buf) {
|
|||
dest[j++] = data[i];
|
||||
dest[j] = 0;
|
||||
|
||||
return new String(true, (byte_vec)dest, j);
|
||||
return new String(true, reinterpret_cast<byte_vec>(dest), j);
|
||||
}
|
||||
|
||||
MIME_Multiline::MIME_Multiline() { line = nullptr; }
|
||||
|
@ -378,7 +378,9 @@ MIME_Multiline::~MIME_Multiline() {
|
|||
delete_strings(buffer);
|
||||
}
|
||||
|
||||
void MIME_Multiline::append(int len, const char* data) { buffer.push_back(new String((const u_char*)data, len, true)); }
|
||||
void MIME_Multiline::append(int len, const char* data) {
|
||||
buffer.push_back(new String(reinterpret_cast<const u_char*>(data), len, true));
|
||||
}
|
||||
|
||||
String* MIME_Multiline::get_concatenated_line() {
|
||||
if ( buffer.empty() )
|
||||
|
@ -396,7 +398,7 @@ MIME_Header::MIME_Header(MIME_Multiline* hl) {
|
|||
|
||||
String* s = hl->get_concatenated_line();
|
||||
int len = s->Len();
|
||||
const char* data = (const char*)s->Bytes();
|
||||
const char* data = reinterpret_cast<const char*>(s->Bytes());
|
||||
|
||||
int offset = MIME_get_field_name(len, data, &name);
|
||||
if ( offset < 0 )
|
||||
|
@ -724,7 +726,7 @@ bool MIME_Entity::ParseContentEncodingField(MIME_Header* h) {
|
|||
}
|
||||
|
||||
delete content_encoding_str;
|
||||
content_encoding_str = new String((const u_char*)enc.data, enc.length, true);
|
||||
content_encoding_str = new String(reinterpret_cast<const u_char*>(enc.data), enc.length, true);
|
||||
ParseContentEncoding(enc);
|
||||
|
||||
if ( need_to_parse_parameters ) {
|
||||
|
@ -782,7 +784,7 @@ bool MIME_Entity::ParseFieldParameters(int len, const char* data) {
|
|||
|
||||
data_chunk_t vd = get_data_chunk(val);
|
||||
delete multipart_boundary;
|
||||
multipart_boundary = new String((const u_char*)vd.data, vd.length, true);
|
||||
multipart_boundary = new String(reinterpret_cast<const u_char*>(vd.data), vd.length, true);
|
||||
}
|
||||
else
|
||||
// token or quoted-string
|
||||
|
@ -1246,18 +1248,18 @@ void MIME_Mail::SubmitAllHeaders(MIME_HeaderList& hlist) {
|
|||
}
|
||||
|
||||
void MIME_Mail::SubmitData(int len, const char* buf) {
|
||||
if ( buf != (char*)data_buffer->Bytes() + buffer_start ) {
|
||||
if ( buf != reinterpret_cast<char*>(data_buffer->Bytes()) + buffer_start ) {
|
||||
reporter->AnalyzerError(GetAnalyzer(), "MIME buffer misalignment");
|
||||
return;
|
||||
}
|
||||
|
||||
if ( compute_content_hash ) {
|
||||
content_hash_length += len;
|
||||
zeek::detail::hash_update(md5_hash, (const u_char*)buf, len);
|
||||
zeek::detail::hash_update(md5_hash, reinterpret_cast<const u_char*>(buf), len);
|
||||
}
|
||||
|
||||
if ( mime_entity_data || mime_all_data ) {
|
||||
String* s = new String((const u_char*)buf, len, false);
|
||||
String* s = new String(reinterpret_cast<const u_char*>(buf), len, false);
|
||||
|
||||
if ( mime_entity_data )
|
||||
entity_content.push_back(s);
|
||||
|
@ -1266,7 +1268,7 @@ void MIME_Mail::SubmitData(int len, const char* buf) {
|
|||
}
|
||||
|
||||
if ( mime_segment_data ) {
|
||||
const char* data = (char*)data_buffer->Bytes() + data_start;
|
||||
const char* data = reinterpret_cast<char*>(data_buffer->Bytes()) + data_start;
|
||||
int data_len = (buf + len) - data;
|
||||
|
||||
analyzer->EnqueueConnEvent(mime_segment_data, analyzer->ConnVal(), val_mgr->Count(data_len),
|
||||
|
@ -1277,7 +1279,7 @@ void MIME_Mail::SubmitData(int len, const char* buf) {
|
|||
analyzer->Conn(), is_orig, cur_entity_id);
|
||||
|
||||
cur_entity_len += len;
|
||||
buffer_start = (buf + len) - (char*)data_buffer->Bytes();
|
||||
buffer_start = (buf + len) - reinterpret_cast<char*>(data_buffer->Bytes());
|
||||
}
|
||||
|
||||
bool MIME_Mail::RequestBuffer(int* plen, char** pbuf) {
|
||||
|
@ -1297,7 +1299,7 @@ bool MIME_Mail::RequestBuffer(int* plen, char** pbuf) {
|
|||
}
|
||||
|
||||
*plen = max_chunk_length - overlap;
|
||||
*pbuf = (char*)data_buffer->Bytes() + buffer_start;
|
||||
*pbuf = reinterpret_cast<char*>(data_buffer->Bytes()) + buffer_start;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -106,11 +106,11 @@ void NetbiosSSN_Interpreter::ParseBroadcast(const u_char* data, int len, bool is
|
|||
// FIND THE NUL-TERMINATED NAME STRINGS HERE!
|
||||
// Not sure what's in them, so we don't keep them currently.
|
||||
|
||||
String* srcname = new String((char*)data);
|
||||
String* srcname = new String(reinterpret_cast<const char*>(data));
|
||||
data += srcname->Len() + 1;
|
||||
len -= srcname->Len();
|
||||
|
||||
String* dstname = new String((char*)data);
|
||||
String* dstname = new String(reinterpret_cast<const char*>(data));
|
||||
data += dstname->Len() + 1;
|
||||
len -= dstname->Len();
|
||||
|
||||
|
@ -150,7 +150,7 @@ void NetbiosSSN_Interpreter::ParseMessageUDP(const u_char* data, int len, bool i
|
|||
}
|
||||
|
||||
void NetbiosSSN_Interpreter::ParseSessionMsg(const u_char* data, int len, bool is_query) {
|
||||
if ( len < 4 || strncmp((const char*)data, "\xffSMB", 4) != 0 ) {
|
||||
if ( len < 4 || strncmp(reinterpret_cast<const char*>(data), "\xffSMB", 4) != 0 ) {
|
||||
// This should be an event, too.
|
||||
analyzer->Weird("netbios_raw_session_msg");
|
||||
Event(netbios_session_raw_message, data, len, is_query);
|
||||
|
|
|
@ -68,7 +68,7 @@ function decode_netbios_name%(name: string%): string
|
|||
--length;
|
||||
}
|
||||
|
||||
return zeek::make_intrusive<zeek::StringVal>(length, (const char *)buf);
|
||||
return zeek::make_intrusive<zeek::StringVal>(length, reinterpret_cast<const char *>(buf));
|
||||
%}
|
||||
|
||||
## Converts a NetBIOS name type to its corresponding numeric value.
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
default:
|
||||
{
|
||||
const uint8* d = ${nsm.reference_id}.data();
|
||||
rv->Assign(7, zeek::make_intrusive<zeek::AddrVal>(zeek::IPAddr(IPv4, (const uint32*) d, zeek::IPAddr::Network)));
|
||||
rv->Assign(7, zeek::make_intrusive<zeek::AddrVal>(zeek::IPAddr(IPv4, reinterpret_cast<const uint32*>(d), zeek::IPAddr::Network)));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -195,8 +195,8 @@ void PIA::FirstPacket(bool is_orig, const std::optional<TransportProto>& proto,
|
|||
DBG_LOG(DBG_ANALYZER, "PIA/TCP FirstPacket(%s)", (is_orig ? "T" : "F"));
|
||||
|
||||
if ( ! ip4_tcp_hdr ) {
|
||||
ip4_tcp = (struct ip*)dummy_packet;
|
||||
tcp4 = (struct tcphdr*)(dummy_packet + sizeof(struct ip));
|
||||
ip4_tcp = reinterpret_cast<struct ip*>(dummy_packet);
|
||||
tcp4 = reinterpret_cast<tcphdr*>(dummy_packet + sizeof(struct ip));
|
||||
ip4_tcp->ip_len = sizeof(struct ip) + sizeof(struct tcphdr);
|
||||
ip4_tcp->ip_hl = sizeof(struct ip) >> 2;
|
||||
|
||||
|
@ -234,8 +234,8 @@ void PIA::FirstPacket(bool is_orig, const std::optional<TransportProto>& proto,
|
|||
DBG_LOG(DBG_ANALYZER, "PIA/UDP FirstPacket(%s)", (is_orig ? "T" : "F"));
|
||||
|
||||
if ( ! ip4_udp_hdr ) {
|
||||
ip4_udp = (struct ip*)dummy_packet;
|
||||
udp4 = (struct udphdr*)(dummy_packet + sizeof(struct ip));
|
||||
ip4_udp = reinterpret_cast<struct ip*>(dummy_packet);
|
||||
udp4 = reinterpret_cast<struct udphdr*>(dummy_packet + sizeof(struct ip));
|
||||
ip4_udp->ip_len = sizeof(struct ip) + sizeof(struct udphdr);
|
||||
ip4_udp->ip_hl = sizeof(struct ip) >> 2;
|
||||
|
||||
|
@ -278,7 +278,7 @@ void PIA::FirstPacket(bool is_orig, const std::optional<TransportProto>& proto,
|
|||
assert(ip);
|
||||
|
||||
if ( ! MatcherInitialized(is_orig) )
|
||||
DoMatch((const u_char*)"", 0, is_orig, true, false, false, ip);
|
||||
DoMatch(reinterpret_cast<const u_char*>(""), 0, is_orig, true, false, false, ip);
|
||||
}
|
||||
|
||||
void PIA_TCP::DeliverStream(int len, const u_char* data, bool is_orig) {
|
||||
|
|
|
@ -70,9 +70,9 @@ void POP3_Analyzer::DeliverStream(int len, const u_char* data, bool orig) {
|
|||
String terminated_string(data, len, true);
|
||||
|
||||
if ( orig )
|
||||
ProcessRequest(len, (char*)terminated_string.Bytes());
|
||||
ProcessRequest(len, reinterpret_cast<char*>(terminated_string.Bytes()));
|
||||
else
|
||||
ProcessReply(len, (char*)terminated_string.Bytes());
|
||||
ProcessReply(len, reinterpret_cast<char*>(terminated_string.Bytes()));
|
||||
}
|
||||
|
||||
static std::string trim_whitespace(const char* in) {
|
||||
|
@ -142,7 +142,7 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line) {
|
|||
case detail::AUTH_PLAIN: {
|
||||
// Format: "authorization identity<NUL>authentication
|
||||
// identity<NUL>password"
|
||||
char* str = (char*)decoded->Bytes();
|
||||
char* str = reinterpret_cast<char*>(decoded->Bytes());
|
||||
int len = decoded->Len();
|
||||
char* end = str + len;
|
||||
char* s;
|
||||
|
@ -177,7 +177,7 @@ void POP3_Analyzer::ProcessRequest(int length, const char* line) {
|
|||
|
||||
case detail::AUTH_CRAM_MD5: { // Format: "user<space>password-hash"
|
||||
const char* s;
|
||||
const char* str = (char*)decoded->CheckString();
|
||||
const char* str = reinterpret_cast<const char*>(decoded->CheckString());
|
||||
|
||||
for ( s = str; *s && *s != '\t' && *s != ' '; ++s )
|
||||
;
|
||||
|
|
|
@ -52,7 +52,7 @@ refine flow RFB_Flow += {
|
|||
auto name_ptr = &((*vec_ptr)[0]);
|
||||
zeek::BifEvent::enqueue_rfb_server_parameters(
|
||||
connection()->zeek_analyzer(), connection()->zeek_analyzer()->Conn(),
|
||||
zeek::make_intrusive<zeek::StringVal>(${msg.name}->size(), (const char*)name_ptr),
|
||||
zeek::make_intrusive<zeek::StringVal>(${msg.name}->size(), reinterpret_cast<const char*>(name_ptr)),
|
||||
${msg.width},
|
||||
${msg.height});
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ refine flow SIP_Flow += {
|
|||
if ( name.length() > 0 )
|
||||
{
|
||||
// Make it all uppercase.
|
||||
name_val = zeek::make_intrusive<zeek::StringVal>(name.length(), (const char*) name.begin());
|
||||
name_val = zeek::make_intrusive<zeek::StringVal>(name.length(), reinterpret_cast<const char*>(name.begin()));
|
||||
name_val->ToUpper();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -39,7 +39,8 @@ bool SMB_Analyzer::HasSMBHeader(int len, const u_char* data) {
|
|||
if ( len < 8 )
|
||||
return false;
|
||||
|
||||
return (strncmp((const char*)data + 4, "\xffSMB", 4) == 0 || strncmp((const char*)data + 4, "\xfeSMB", 4) == 0);
|
||||
return (strncmp(reinterpret_cast<const char*>(data) + 4, "\xffSMB", 4) == 0 ||
|
||||
strncmp(reinterpret_cast<const char*>(data) + 4, "\xfeSMB", 4) == 0);
|
||||
}
|
||||
|
||||
void SMB_Analyzer::NeedResync() {
|
||||
|
|
|
@ -36,7 +36,7 @@ refine connection SMB_Conn += {
|
|||
// We check if this is the case and run the NTLM analyzer directly.
|
||||
if ( ${data}.length() >= 8 )
|
||||
{
|
||||
if ( strncmp((const char*)${data}.begin(), "NTLMSSP",7) == 0 )
|
||||
if ( strncmp(reinterpret_cast<const char*>(${data}.begin()), "NTLMSSP",7) == 0 )
|
||||
{
|
||||
if ( ntlm )
|
||||
ntlm->DeliverStream(${data}.length(), ${data}.begin(), is_orig);
|
||||
|
|
|
@ -16,7 +16,7 @@ refine connection SMB_Conn += {
|
|||
args->Assign(7, ${val.data_displacement});
|
||||
|
||||
auto parameters = zeek::make_intrusive<zeek::StringVal>(${val.parameters}.length(),
|
||||
(const char*)${val.parameters}.data());
|
||||
reinterpret_cast<const char*>(${val.parameters}.data()));
|
||||
zeek::StringValPtr payload_str;
|
||||
|
||||
if ( ${val.data_count} > 0 )
|
||||
|
|
|
@ -54,7 +54,7 @@ refine connection SMB_Conn += {
|
|||
return false;
|
||||
|
||||
auto parameters = zeek::make_intrusive<zeek::StringVal>(${val.parameters}.length(),
|
||||
(const char*)${val.parameters}.data());
|
||||
reinterpret_cast<const char*>(${val.parameters}.data()));
|
||||
zeek::StringValPtr payload_str;
|
||||
|
||||
if ( ${val.data_count} > 0 )
|
||||
|
@ -79,7 +79,7 @@ refine connection SMB_Conn += {
|
|||
return false;
|
||||
|
||||
auto parameters = zeek::make_intrusive<zeek::StringVal>(${val.parameters}.length(),
|
||||
(const char*)${val.parameters}.data());
|
||||
reinterpret_cast<const char*>(${val.parameters}.data()));
|
||||
zeek::StringValPtr payload_str;
|
||||
|
||||
if ( ${val.data_count} > 0 )
|
||||
|
|
|
@ -16,8 +16,8 @@ refine connection SMB_Conn += {
|
|||
args->Assign(7, ${val.data_displacement});
|
||||
args->Assign(8, ${val.FID});
|
||||
|
||||
auto parameters = zeek::make_intrusive<zeek::StringVal>(${val.parameters}.length(), (const char*)${val.parameters}.data());
|
||||
auto payload = zeek::make_intrusive<zeek::StringVal>(${val.data}.length(), (const char*)${val.data}.data());
|
||||
auto parameters = zeek::make_intrusive<zeek::StringVal>(${val.parameters}.length(), reinterpret_cast<const char*>(${val.parameters}.data()));
|
||||
auto payload = zeek::make_intrusive<zeek::StringVal>(${val.data}.length(), reinterpret_cast<const char*>(${val.data}.data()));
|
||||
|
||||
zeek::BifEvent::enqueue_smb1_transaction2_secondary_request(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
|
|
|
@ -162,7 +162,7 @@ void SMTP_Analyzer::DeliverStream(int length, const u_char* line, bool orig) {
|
|||
// Some weird client uses '\r\r\n' for end-of-line sequence
|
||||
// So we make a compromise here to allow /(\r)*\n/ as end-of-line sequences
|
||||
if ( length > 0 && line[length - 1] == '\r' ) {
|
||||
Unexpected(is_sender, "more than one <CR> at the end of line", length, (const char*)line);
|
||||
Unexpected(is_sender, "more than one <CR> at the end of line", length, reinterpret_cast<const char*>(line));
|
||||
do
|
||||
--length;
|
||||
while ( length > 0 && line[length - 1] == '\r' );
|
||||
|
@ -170,11 +170,12 @@ void SMTP_Analyzer::DeliverStream(int length, const u_char* line, bool orig) {
|
|||
|
||||
for ( int i = 0; i < length; ++i )
|
||||
if ( line[i] == '\r' || line[i] == '\n' ) {
|
||||
Unexpected(is_sender, "Bare <CR> or <LF> appears in the middle of line", length, (const char*)line);
|
||||
Unexpected(is_sender, "Bare <CR> or <LF> appears in the middle of line", length,
|
||||
reinterpret_cast<const char*>(line));
|
||||
break;
|
||||
}
|
||||
|
||||
ProcessLine(length, (const char*)line, orig);
|
||||
ProcessLine(length, reinterpret_cast<const char*>(line), orig);
|
||||
}
|
||||
|
||||
void SMTP_Analyzer::ProcessLine(int length, const char* line, bool orig) {
|
||||
|
@ -196,7 +197,7 @@ void SMTP_Analyzer::ProcessLine(int length, const char* line, bool orig) {
|
|||
// a data line.
|
||||
delete line_after_gap;
|
||||
|
||||
line_after_gap = new String((const u_char*)line, length, true);
|
||||
line_after_gap = new String(reinterpret_cast<const u_char*>(line), length, true);
|
||||
}
|
||||
|
||||
else if ( state == detail::SMTP_IN_DATA && line[0] == '.' && length == 1 ) {
|
||||
|
|
|
@ -94,11 +94,11 @@ refine connection SOCKS_Conn += {
|
|||
|
||||
case 3:
|
||||
sa->Assign(1, zeek::make_intrusive<zeek::StringVal>(${request.remote_name.domain_name.name}.length(),
|
||||
(const char*) ${request.remote_name.domain_name.name}.data()));
|
||||
reinterpret_cast<const char*>(${request.remote_name.domain_name.name}.data())));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
sa->Assign(0, zeek::make_intrusive<zeek::AddrVal>(zeek::IPAddr(IPv6, (const uint32_t*) ${request.remote_name.ipv6}, zeek::IPAddr::Network)));
|
||||
sa->Assign(0, zeek::make_intrusive<zeek::AddrVal>(zeek::IPAddr(IPv6, reinterpret_cast<const uint32_t*>(${request.remote_name.ipv6}), zeek::IPAddr::Network)));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -134,11 +134,11 @@ refine connection SOCKS_Conn += {
|
|||
|
||||
case 3:
|
||||
sa->Assign(1, zeek::make_intrusive<zeek::StringVal>(${reply.bound.domain_name.name}.length(),
|
||||
(const char*) ${reply.bound.domain_name.name}.data()));
|
||||
reinterpret_cast<const char*>(${reply.bound.domain_name.name}.data())));
|
||||
break;
|
||||
|
||||
case 4:
|
||||
sa->Assign(0, zeek::make_intrusive<zeek::AddrVal>(zeek::IPAddr(IPv6, (const uint32_t*) ${reply.bound.ipv6}, zeek::IPAddr::Network)));
|
||||
sa->Assign(0, zeek::make_intrusive<zeek::AddrVal>(zeek::IPAddr(IPv6, reinterpret_cast<const uint32_t*>(${reply.bound.ipv6}), zeek::IPAddr::Network)));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -164,8 +164,8 @@ refine connection SOCKS_Conn += {
|
|||
if ( ! socks_login_userpass_request )
|
||||
return true;
|
||||
|
||||
auto user = zeek::make_intrusive<zeek::StringVal>(${request.username}.length(), (const char*) ${request.username}.begin());
|
||||
auto pass = zeek::make_intrusive<zeek::StringVal>(${request.password}.length(), (const char*) ${request.password}.begin());
|
||||
auto user = zeek::make_intrusive<zeek::StringVal>(request->username().length(), reinterpret_cast<const char*>(${request.username}.begin()));
|
||||
auto pass = zeek::make_intrusive<zeek::StringVal>(request->password().length(), reinterpret_cast<const char*>(${request.password}.begin()));
|
||||
|
||||
zeek::BifEvent::enqueue_socks_login_userpass_request(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
|
|
|
@ -54,8 +54,8 @@ void DTLS_Analyzer::SendHandshake(uint16_t raw_tls_version, uint8_t msg_type, ui
|
|||
// the parser inspects a uint24_t - since it is big-endian, it should be ok to just skip
|
||||
// the first byte of the uint32_t. Since we get the data from an uint24_t from the
|
||||
// dtls-parser, this should always yield the correct result.
|
||||
handshake_interp->NewData(orig, (const unsigned char*)&host_length + 1,
|
||||
(const unsigned char*)&host_length + sizeof(host_length));
|
||||
handshake_interp->NewData(orig, reinterpret_cast<const unsigned char*>(&host_length) + 1,
|
||||
reinterpret_cast<const unsigned char*>(&host_length) + sizeof(host_length));
|
||||
handshake_interp->NewData(orig, begin, end);
|
||||
} catch ( const binpac::Exception& e ) {
|
||||
AnalyzerViolation(util::fmt("Binpac exception: %s", e.c_msg()));
|
||||
|
|
|
@ -122,7 +122,7 @@ void SSL_Analyzer::SetSecret(const zeek::StringVal& secret) { SetSecret(secret.L
|
|||
|
||||
void SSL_Analyzer::SetSecret(size_t len, const u_char* data) {
|
||||
secret.clear();
|
||||
secret.append((const char*)data, len);
|
||||
secret.append(reinterpret_cast<const char*>(data), len);
|
||||
}
|
||||
|
||||
void SSL_Analyzer::SetKeys(const zeek::StringVal& nkeys) {
|
||||
|
|
|
@ -49,7 +49,7 @@ refine connection SSL_Conn += {
|
|||
zeek::BifEvent::enqueue_ssl_client_hello(zeek_analyzer(), zeek_analyzer()->Conn(),
|
||||
version, record_version(), ts,
|
||||
zeek::make_intrusive<zeek::StringVal>(client_random.length(),
|
||||
(const char*) client_random.data()),
|
||||
reinterpret_cast<const char*>(client_random.data())),
|
||||
{zeek::AdoptRef{}, to_string_val(session_id)},
|
||||
std::move(cipher_vec), std::move(comp_vec));
|
||||
}
|
||||
|
@ -81,13 +81,13 @@ refine connection SSL_Conn += {
|
|||
|
||||
uint32 ts = 0;
|
||||
if ( v2 == 0 && server_random.length() >= 4 )
|
||||
ts = ntohl(*((uint32*)server_random.data()));
|
||||
ts = ntohl(*(reinterpret_cast<uint32*>(server_random.data())));
|
||||
|
||||
zeek::BifEvent::enqueue_ssl_server_hello(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
version, record_version(), ts,
|
||||
zeek::make_intrusive<zeek::StringVal>(server_random.length(),
|
||||
(const char*) server_random.data()),
|
||||
reinterpret_cast<const char*>(server_random.data())),
|
||||
{zeek::AdoptRef{}, to_string_val(session_id)},
|
||||
first_cipher, comp_method);
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ refine connection SSL_Conn += {
|
|||
if ( ssl_heartbeat )
|
||||
zeek::BifEvent::enqueue_ssl_heartbeat(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(), ${rec.is_orig} ^ zeek_analyzer()->GetFlipped(), ${rec.length}, type, payload_length,
|
||||
zeek::make_intrusive<zeek::StringVal>(data.length(), (const char*) data.data()));
|
||||
zeek::make_intrusive<zeek::StringVal>(data.length(), reinterpret_cast<const char*>(data.data())));
|
||||
return true;
|
||||
%}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ refine connection Handshake_Conn += {
|
|||
zeek::BifEvent::enqueue_ssl_client_hello(zeek_analyzer(), zeek_analyzer()->Conn(),
|
||||
version, record_version(), ts,
|
||||
zeek::make_intrusive<zeek::StringVal>(client_random.length(),
|
||||
(const char*) client_random.data()),
|
||||
reinterpret_cast<const char*>(client_random.data())),
|
||||
{zeek::AdoptRef{}, to_string_val(session_id)},
|
||||
std::move(cipher_vec), std::move(comp_vec));
|
||||
}
|
||||
|
@ -109,14 +109,14 @@ refine connection Handshake_Conn += {
|
|||
|
||||
uint32 ts = 0;
|
||||
if ( v2 == 0 && server_random.length() >= 4 )
|
||||
ts = ntohl(*((uint32*)server_random.data()));
|
||||
ts = ntohl(*(reinterpret_cast<uint32*>(server_random.data())));
|
||||
|
||||
set_server_random(server_random);
|
||||
zeek::BifEvent::enqueue_ssl_server_hello(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
version, record_version(), ts,
|
||||
zeek::make_intrusive<zeek::StringVal>(server_random.length(),
|
||||
(const char*) server_random.data()),
|
||||
reinterpret_cast<const char*>(server_random.data())),
|
||||
{zeek::AdoptRef{}, to_string_val(session_id)},
|
||||
ciphers->size()==0 ? 0 : ciphers->at(0), comp_method);
|
||||
|
||||
|
@ -133,7 +133,7 @@ refine connection Handshake_Conn += {
|
|||
zeek::BifEvent::enqueue_ssl_session_ticket_handshake(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
${rec.ticket_lifetime_hint},
|
||||
zeek::make_intrusive<zeek::StringVal>(${rec.data}.length(), (const char*) ${rec.data}.data()));
|
||||
zeek::make_intrusive<zeek::StringVal>(${rec.data}.length(), reinterpret_cast<const char*>(${rec.data}.data())));
|
||||
}
|
||||
return true;
|
||||
%}
|
||||
|
@ -279,7 +279,7 @@ refine connection Handshake_Conn += {
|
|||
if ( protocols )
|
||||
{
|
||||
for ( unsigned int i = 0; i < protocols->size(); ++i )
|
||||
plist->Assign(i, zeek::make_intrusive<zeek::StringVal>((*protocols)[i]->name().length(), (const char*) (*protocols)[i]->name().data()));
|
||||
plist->Assign(i, zeek::make_intrusive<zeek::StringVal>((*protocols)[i]->name().length(), reinterpret_cast<const char*>((*protocols)[i]->name().data())));
|
||||
}
|
||||
|
||||
zeek::BifEvent::enqueue_ssl_extension_application_layer_protocol_negotiation(zeek_analyzer(), zeek_analyzer()->Conn(),
|
||||
|
@ -304,7 +304,7 @@ refine connection Handshake_Conn += {
|
|||
}
|
||||
|
||||
if ( servername->host_name() )
|
||||
servers->Assign(j++, zeek::make_intrusive<zeek::StringVal>(servername->host_name()->host_name().length(), (const char*) servername->host_name()->host_name().data()));
|
||||
servers->Assign(j++, zeek::make_intrusive<zeek::StringVal>(servername->host_name()->host_name().length(), reinterpret_cast<const char*>(servername->host_name()->host_name().data())));
|
||||
else
|
||||
zeek_analyzer()->Weird("Empty server_name extension in ssl connection");
|
||||
}
|
||||
|
@ -412,7 +412,7 @@ refine connection Handshake_Conn += {
|
|||
zeek::BifEvent::enqueue_ssl_stapled_ocsp(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
${rec.is_orig} ^ flipped_,
|
||||
zeek::make_intrusive<zeek::StringVal>(response.length(), (const char*) response.data()));
|
||||
zeek::make_intrusive<zeek::StringVal>(response.length(), reinterpret_cast<const char*>(response.data())));
|
||||
|
||||
zeek::file_mgr->EndOfFile(file_id);
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ refine connection Handshake_Conn += {
|
|||
zeek::BifEvent::enqueue_ssl_ecdh_server_params(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
${kex.params.curve},
|
||||
zeek::make_intrusive<zeek::StringVal>(${kex.params.point}.length(), (const char*)${kex.params.point}.data()));
|
||||
zeek::make_intrusive<zeek::StringVal>(${kex.params.point}.length(), reinterpret_cast<const char*>(${kex.params.point}.data())));
|
||||
|
||||
if ( ssl_server_signature )
|
||||
{
|
||||
|
@ -454,7 +454,7 @@ refine connection Handshake_Conn += {
|
|||
zeek::BifEvent::enqueue_ssl_server_signature(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
std::move(ha),
|
||||
zeek::make_intrusive<zeek::StringVal>(${kex.signed_params.signature}.length(), (const char*)(${kex.signed_params.signature}).data()));
|
||||
zeek::make_intrusive<zeek::StringVal>(${kex.signed_params.signature}.length(), reinterpret_cast<const char*>(${kex.signed_params.signature}.data())));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -469,7 +469,7 @@ refine connection Handshake_Conn += {
|
|||
zeek::BifEvent::enqueue_ssl_ecdh_server_params(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
${kex.params.curve},
|
||||
zeek::make_intrusive<zeek::StringVal>(${kex.params.point}.length(), (const char*)${kex.params.point}.data()));
|
||||
zeek::make_intrusive<zeek::StringVal>(${kex.params.point}.length(), reinterpret_cast<const char*>(${kex.params.point}.data())));
|
||||
|
||||
return true;
|
||||
%}
|
||||
|
@ -479,7 +479,7 @@ refine connection Handshake_Conn += {
|
|||
if ( ssl_rsa_client_pms )
|
||||
zeek::BifEvent::enqueue_ssl_rsa_client_pms(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
zeek::make_intrusive<zeek::StringVal>(rsa_pms.length(), (const char*)rsa_pms.data()));
|
||||
zeek::make_intrusive<zeek::StringVal>(rsa_pms.length(), reinterpret_cast<const char*>(rsa_pms.data())));
|
||||
|
||||
return true;
|
||||
%}
|
||||
|
@ -489,7 +489,7 @@ refine connection Handshake_Conn += {
|
|||
if ( ssl_dh_client_params )
|
||||
zeek::BifEvent::enqueue_ssl_dh_client_params(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
zeek::make_intrusive<zeek::StringVal>(Yc.length(), (const char*)Yc.data()));
|
||||
zeek::make_intrusive<zeek::StringVal>(Yc.length(), reinterpret_cast<const char*>(Yc.data())));
|
||||
|
||||
return true;
|
||||
%}
|
||||
|
@ -499,7 +499,7 @@ refine connection Handshake_Conn += {
|
|||
if ( ssl_ecdh_client_params )
|
||||
zeek::BifEvent::enqueue_ssl_ecdh_client_params(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
zeek::make_intrusive<zeek::StringVal>(point.length(), (const char*)point.data()));
|
||||
zeek::make_intrusive<zeek::StringVal>(point.length(), reinterpret_cast<const char*>(point.data())));
|
||||
|
||||
return true;
|
||||
%}
|
||||
|
@ -530,9 +530,9 @@ refine connection Handshake_Conn += {
|
|||
if ( ssl_ecdh_server_params )
|
||||
zeek::BifEvent::enqueue_ssl_dh_server_params(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
zeek::make_intrusive<zeek::StringVal>(p.length(), (const char*) p.data()),
|
||||
zeek::make_intrusive<zeek::StringVal>(g.length(), (const char*) g.data()),
|
||||
zeek::make_intrusive<zeek::StringVal>(Ys.length(), (const char*) Ys.data())
|
||||
zeek::make_intrusive<zeek::StringVal>(p.length(), reinterpret_cast<const char*>(p.data())),
|
||||
zeek::make_intrusive<zeek::StringVal>(g.length(), reinterpret_cast<const char*>(g.data())),
|
||||
zeek::make_intrusive<zeek::StringVal>(Ys.length(), reinterpret_cast<const char*>(Ys.data()))
|
||||
);
|
||||
|
||||
if ( ssl_server_signature )
|
||||
|
@ -553,7 +553,7 @@ refine connection Handshake_Conn += {
|
|||
|
||||
zeek::BifEvent::enqueue_ssl_server_signature(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(), std::move(ha),
|
||||
zeek::make_intrusive<zeek::StringVal>(${signed_params.signature}.length(), (const char*)(${signed_params.signature}).data())
|
||||
zeek::make_intrusive<zeek::StringVal>(${signed_params.signature}.length(), reinterpret_cast<const char*>(${signed_params.signature}.data()))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -565,9 +565,9 @@ refine connection Handshake_Conn += {
|
|||
if ( ssl_dh_server_params )
|
||||
zeek::BifEvent::enqueue_ssl_dh_server_params(zeek_analyzer(),
|
||||
zeek_analyzer()->Conn(),
|
||||
zeek::make_intrusive<zeek::StringVal>(p.length(), (const char*) p.data()),
|
||||
zeek::make_intrusive<zeek::StringVal>(g.length(), (const char*) g.data()),
|
||||
zeek::make_intrusive<zeek::StringVal>(Ys.length(), (const char*) Ys.data())
|
||||
zeek::make_intrusive<zeek::StringVal>(p.length(), reinterpret_cast<const char*>(p.data())),
|
||||
zeek::make_intrusive<zeek::StringVal>(g.length(), reinterpret_cast<const char*>(g.data())),
|
||||
zeek::make_intrusive<zeek::StringVal>(Ys.length(), reinterpret_cast<const char*>(Ys.data()))
|
||||
);
|
||||
|
||||
return true;
|
||||
|
@ -594,7 +594,7 @@ refine connection Handshake_Conn += {
|
|||
for ( auto&& identity : *(identities->identities()) )
|
||||
{
|
||||
auto el = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::SSL::PSKIdentity);
|
||||
el->Assign(0, zeek::make_intrusive<zeek::StringVal>(identity->identity().length(), (const char*) identity->identity().data()));
|
||||
el->Assign(0, zeek::make_intrusive<zeek::StringVal>(identity->identity().length(), reinterpret_cast<const char*>(identity->identity().data())));
|
||||
el->Assign(1, identity->obfuscated_ticket_age());
|
||||
slist->Assign(slist->Size(), std::move(el));
|
||||
}
|
||||
|
@ -605,7 +605,7 @@ refine connection Handshake_Conn += {
|
|||
if ( binders && binders->binders() )
|
||||
{
|
||||
for ( auto&& binder : *(binders->binders()) )
|
||||
blist->Assign(blist->Size(), zeek::make_intrusive<zeek::StringVal>(binder->binder().length(), (const char*) binder->binder().data()));
|
||||
blist->Assign(blist->Size(), zeek::make_intrusive<zeek::StringVal>(binder->binder().length(), reinterpret_cast<const char*>(binder->binder().data())));
|
||||
}
|
||||
|
||||
zeek::BifEvent::enqueue_ssl_extension_pre_shared_key_client_hello(zeek_analyzer(), zeek_analyzer()->Conn(),
|
||||
|
@ -661,7 +661,7 @@ refine connection Handshake_Conn += {
|
|||
for ( unsigned int i = 0; i < certificate_authorities->size(); ++i )
|
||||
{
|
||||
auto ca = (*certificate_authorities)[i]->certificate_authority();
|
||||
calist->Assign(i, zeek::make_intrusive<zeek::StringVal>(ca.length(), (const char*) ca.data()));
|
||||
calist->Assign(i, zeek::make_intrusive<zeek::StringVal>(ca.length(), reinterpret_cast<const char*>(ca.data())));
|
||||
}
|
||||
|
||||
zeek::BifEvent::enqueue_ssl_certificate_request(zeek_analyzer(), zeek_analyzer()->Conn(), ${rec.is_orig} ^ flipped_, ctlist, slist, calist);
|
||||
|
@ -674,7 +674,7 @@ refine connection Handshake_Conn += {
|
|||
if ( ! ssl_extension_connection_id )
|
||||
return true;
|
||||
|
||||
auto cid_string = zeek::make_intrusive<zeek::StringVal>(cid.length(), (const char*) cid.data());
|
||||
auto cid_string = zeek::make_intrusive<zeek::StringVal>(cid.length(), reinterpret_cast<const char*>(cid.data()));
|
||||
zeek::BifEvent::enqueue_ssl_extension_connection_id(zeek_analyzer(), zeek_analyzer()->Conn(), ${rec.is_orig} ^ flipped_, std::move(cid_string));
|
||||
|
||||
return true;
|
||||
|
|
|
@ -88,7 +88,7 @@ void ContentLine_Analyzer::DeliverStream(int len, const u_char* data, bool is_or
|
|||
if ( delivery_length == 0 ) {
|
||||
if ( HasPartialLine() ) {
|
||||
Weird("line_terminated_without_CRLF");
|
||||
DoDeliver(2, (const u_char*)"\r\n");
|
||||
DoDeliver(2, reinterpret_cast<const u_char*>("\r\n"));
|
||||
}
|
||||
delivery_length = -1;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ void ContentLine_Analyzer::Undelivered(uint64_t seq, int len, bool orig) { Forwa
|
|||
|
||||
void ContentLine_Analyzer::EndpointEOF(bool is_orig) {
|
||||
if ( offset > 0 )
|
||||
DeliverStream(1, (const u_char*)"\n", is_orig);
|
||||
DeliverStream(1, reinterpret_cast<const u_char*>("\n"), is_orig);
|
||||
}
|
||||
|
||||
void ContentLine_Analyzer::SetPlainDelivery(int64_t length) {
|
||||
|
|
|
@ -40,8 +40,8 @@ void TCP_ApplicationAnalyzer::DeliverPacket(int len, const u_char* data, bool is
|
|||
int caplen) {
|
||||
Analyzer::DeliverPacket(len, data, is_orig, seq, ip, caplen);
|
||||
DBG_LOG(DBG_ANALYZER, "TCP_ApplicationAnalyzer ignoring DeliverPacket(%d, %s, %" PRIu64 ", %p, %d) [%s%s]", len,
|
||||
is_orig ? "T" : "F", seq, ip, caplen, util::fmt_bytes((const char*)data, std::min(40, len)),
|
||||
len > 40 ? "..." : "");
|
||||
is_orig ? "T" : "F", seq, ip, caplen,
|
||||
util::fmt_bytes(reinterpret_cast<const char*>(data), std::min(40, len)), len > 40 ? "..." : "");
|
||||
}
|
||||
|
||||
void TCP_ApplicationAnalyzer::SetEnv(bool /* is_orig */, char* name, char* val) {
|
||||
|
|
|
@ -313,7 +313,7 @@ void TCP_Reassembler::RecordToSeq(uint64_t start_seq, uint64_t stop_seq, const F
|
|||
}
|
||||
|
||||
void TCP_Reassembler::RecordBlock(const DataBlock& b, const FilePtr& f) {
|
||||
if ( f->Write((const char*)b.block, b.Size()) )
|
||||
if ( f->Write(reinterpret_cast<const char*>(b.block), b.Size()) )
|
||||
return;
|
||||
|
||||
reporter->Error("TCP_Reassembler contents write failed");
|
||||
|
@ -537,7 +537,8 @@ void TCP_Reassembler::DeliverBlock(uint64_t seq, int len, const u_char* data) {
|
|||
|
||||
if ( deliver_tcp_contents )
|
||||
tcp_analyzer->EnqueueConnEvent(tcp_contents, tcp_analyzer->ConnVal(), val_mgr->Bool(IsOrig()),
|
||||
val_mgr->Count(seq), make_intrusive<StringVal>(len, (const char*)data));
|
||||
val_mgr->Count(seq),
|
||||
make_intrusive<StringVal>(len, reinterpret_cast<const char*>(data)));
|
||||
|
||||
// Q. Can we say this because it is already checked in DataSent()?
|
||||
// ASSERT(!Conn()->Skipping() && !SkipDeliveries());
|
||||
|
|
|
@ -48,7 +48,7 @@ void ZIP_Analyzer::DeliverStream(int len, const u_char* data, bool orig) {
|
|||
|
||||
int allow_restart = 1;
|
||||
|
||||
zip->next_in = (Bytef*)data;
|
||||
zip->next_in = reinterpret_cast<Bytef*>(const_cast<u_char*>(data));
|
||||
zip->avail_in = len;
|
||||
|
||||
auto orig_next_in = zip->next_in;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
function bytestring_casecmp(s1: const_bytestring, s2: const_charptr): int
|
||||
%{
|
||||
int r = strncasecmp((const char*) s1.begin(), s2, s1.length());
|
||||
int r = strncasecmp(reinterpret_cast<const char*>(s1.begin()), s2, s1.length());
|
||||
if ( r == 0 )
|
||||
return s2[s1.length()] == '\0' ? 0 : -1;
|
||||
else
|
||||
|
@ -15,15 +15,15 @@ function bytestring_casecmp(s1: const_bytestring, s2: const_charptr): int
|
|||
# True if s2 is a (case-insensitive) prefix of s1.
|
||||
function bytestring_caseprefix(s1: const_bytestring, s2: const_charptr): bool
|
||||
%{
|
||||
return strncasecmp((const char*) s1.begin(), s2, strlen(s2)) == 0;
|
||||
return strncasecmp(reinterpret_cast<const char*>(s1.begin()), s2, strlen(s2)) == 0;
|
||||
%}
|
||||
|
||||
function bytestring_to_int(s: const_bytestring, base: int): int
|
||||
%{
|
||||
return strtol((const char*) std_str(s).c_str(), nullptr, base);
|
||||
return strtol(std_str(s).c_str(), nullptr, base);
|
||||
%}
|
||||
|
||||
function bytestring_to_double(s: const_bytestring): double
|
||||
%{
|
||||
return atof((const char*) std_str(s).c_str());
|
||||
return atof(std_str(s).c_str());
|
||||
%}
|
||||
|
|
|
@ -22,7 +22,7 @@ using ZeekStringVal = zeek::StringVal*;
|
|||
using ZeekPacket = zeek::Packet;
|
||||
|
||||
inline zeek::StringValPtr to_stringval(const_bytestring const& str) {
|
||||
return zeek::make_intrusive<zeek::StringVal>(str.length(), (const char*)str.begin());
|
||||
return zeek::make_intrusive<zeek::StringVal>(str.length(), reinterpret_cast<const char*>(str.begin()));
|
||||
}
|
||||
|
||||
zeek::StringValPtr utf16_to_utf8_val(zeek::Connection* conn, const bytestring& utf16);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
namespace zeek::file_analysis::detail {
|
||||
|
||||
static void analyzer_del_func(void* v) {
|
||||
file_analysis::Analyzer* a = (file_analysis::Analyzer*)v;
|
||||
file_analysis::Analyzer* a = reinterpret_cast<file_analysis::Analyzer*>(v);
|
||||
|
||||
a->Done();
|
||||
delete a;
|
||||
|
|
|
@ -318,7 +318,7 @@ void File::DeliverStream(const u_char* data, uint64_t len) {
|
|||
|
||||
DBG_LOG(DBG_FILE_ANALYSIS, "[%s] %" PRIu64 " stream bytes in at offset %" PRIu64 "; %s [%s%s]", id.c_str(), len,
|
||||
stream_offset, IsComplete() ? "complete" : "incomplete",
|
||||
util::fmt_bytes((const char*)data, std::min((uint64_t)40, len)), len > 40 ? "..." : "");
|
||||
util::fmt_bytes(reinterpret_cast<const char*>(data), std::min(uint64_t(40), len)), len > 40 ? "..." : "");
|
||||
|
||||
for ( const auto& entry : analyzers ) {
|
||||
auto* a = entry.value;
|
||||
|
@ -406,7 +406,7 @@ void File::DeliverChunk(const u_char* data, uint64_t len, uint64_t offset) {
|
|||
|
||||
DBG_LOG(DBG_FILE_ANALYSIS, "[%s] %" PRIu64 " chunk bytes in at offset %" PRIu64 "; %s [%s%s]", id.c_str(), len,
|
||||
offset, IsComplete() ? "complete" : "incomplete",
|
||||
util::fmt_bytes((const char*)data, std::min((uint64_t)40, len)), len > 40 ? "..." : "");
|
||||
util::fmt_bytes(reinterpret_cast<const char*>(data), std::min(uint64_t(40), len)), len > 40 ? "..." : "");
|
||||
|
||||
for ( const auto& entry : analyzers ) {
|
||||
auto* a = entry.value;
|
||||
|
@ -454,7 +454,7 @@ void File::EndOfFile() {
|
|||
if ( ! bof_buffer.full ) {
|
||||
DBG_LOG(DBG_FILE_ANALYSIS, "[%s] File over but bof_buffer not full.", id.c_str());
|
||||
bof_buffer.full = true;
|
||||
DeliverStream((const u_char*)"", 0);
|
||||
DeliverStream(reinterpret_cast<const u_char*>(""), 0);
|
||||
}
|
||||
analyzers.DrainModifications();
|
||||
|
||||
|
@ -487,7 +487,7 @@ void File::Gap(uint64_t offset, uint64_t len) {
|
|||
"bof_buffer.",
|
||||
id.c_str());
|
||||
bof_buffer.full = true;
|
||||
DeliverStream((const u_char*)"", 0);
|
||||
DeliverStream(reinterpret_cast<const u_char*>(""), 0);
|
||||
}
|
||||
|
||||
for ( const auto& entry : analyzers ) {
|
||||
|
|
|
@ -115,7 +115,7 @@ TEST_CASE("file reassembler") {
|
|||
auto f = std::make_unique<TestFile>("test_file_id", "test_source_name");
|
||||
auto r = std::make_unique<zeek::file_analysis::FileReassembler>(f.get(), 0);
|
||||
|
||||
const u_char* data = (u_char*)("0123456789ABCDEF");
|
||||
const u_char* data = reinterpret_cast<const u_char*>("0123456789ABCDEF");
|
||||
|
||||
SUBCASE("block overlap and 64bit overflow") {
|
||||
r->NewBlock(0.0, 0xfffffffffffffff7, 3, data);
|
||||
|
|
|
@ -48,7 +48,7 @@ refine flow File += {
|
|||
if ( pe_dos_header )
|
||||
{
|
||||
auto dh = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::PE::DOSHeader);
|
||||
dh->Assign(0, zeek::make_intrusive<zeek::StringVal>(${h.signature}.length(), (const char*) ${h.signature}.data()));
|
||||
dh->Assign(0, zeek::make_intrusive<zeek::StringVal>(${h.signature}.length(), reinterpret_cast<const char*>(${h.signature}.data())));
|
||||
dh->Assign(1, ${h.UsedBytesInTheLastPage});
|
||||
dh->Assign(2, ${h.FileSizeInPages});
|
||||
dh->Assign(3, ${h.NumberOfRelocationItems});
|
||||
|
@ -78,7 +78,7 @@ refine flow File += {
|
|||
if ( pe_dos_code )
|
||||
zeek::event_mgr.Enqueue(pe_dos_code,
|
||||
connection()->zeek_analyzer()->GetFile()->ToVal(),
|
||||
zeek::make_intrusive<zeek::StringVal>(code.length(), (const char*) code.data())
|
||||
zeek::make_intrusive<zeek::StringVal>(code.length(), reinterpret_cast<const char*>(code.data()))
|
||||
);
|
||||
return true;
|
||||
%}
|
||||
|
@ -170,13 +170,13 @@ refine flow File += {
|
|||
auto section_header = zeek::make_intrusive<zeek::RecordVal>(zeek::BifType::Record::PE::SectionHeader);
|
||||
|
||||
// Strip null characters from the end of the section name.
|
||||
u_char* first_null = (u_char*) memchr(${h.name}.data(), 0, ${h.name}.length());
|
||||
u_char* first_null = reinterpret_cast<u_char*>(memchr(${h.name}.data(), 0, ${h.name}.length()));
|
||||
uint16 name_len;
|
||||
if ( first_null == nullptr )
|
||||
name_len = ${h.name}.length();
|
||||
else
|
||||
name_len = first_null - ${h.name}.data();
|
||||
section_header->Assign(0, zeek::make_intrusive<zeek::StringVal>(name_len, (const char*) ${h.name}.data()));
|
||||
section_header->Assign(0, zeek::make_intrusive<zeek::StringVal>(name_len, reinterpret_cast<const char*>(${h.name}.data())));
|
||||
|
||||
section_header->Assign(1, ${h.virtual_size});
|
||||
section_header->Assign(2, ${h.virtual_addr});
|
||||
|
|
|
@ -279,7 +279,7 @@ void X509::FreeRootStore() {
|
|||
void X509::ParseBasicConstraints(X509_EXTENSION* ex) {
|
||||
assert(OBJ_obj2nid(X509_EXTENSION_get_object(ex)) == NID_basic_constraints);
|
||||
|
||||
BASIC_CONSTRAINTS* constr = (BASIC_CONSTRAINTS*)X509V3_EXT_d2i(ex);
|
||||
BASIC_CONSTRAINTS* constr = reinterpret_cast<BASIC_CONSTRAINTS*>(X509V3_EXT_d2i(ex));
|
||||
|
||||
if ( constr ) {
|
||||
if ( x509_ext_basic_constraints ) {
|
||||
|
@ -321,7 +321,7 @@ void X509::ParseExtensionsSpecific(X509_EXTENSION* ex, bool global, ASN1_OBJECT*
|
|||
void X509::ParseSAN(X509_EXTENSION* ext) {
|
||||
assert(OBJ_obj2nid(X509_EXTENSION_get_object(ext)) == NID_subject_alt_name);
|
||||
|
||||
GENERAL_NAMES* altname = (GENERAL_NAMES*)X509V3_EXT_d2i(ext);
|
||||
GENERAL_NAMES* altname = reinterpret_cast<GENERAL_NAMES*>(X509V3_EXT_d2i(ext));
|
||||
if ( ! altname ) {
|
||||
reporter->Weird(GetFile(), "x509_san_parse_error");
|
||||
return;
|
||||
|
@ -345,7 +345,7 @@ void X509::ParseSAN(X509_EXTENSION* ext) {
|
|||
}
|
||||
|
||||
auto len = ASN1_STRING_length(gen->d.ia5);
|
||||
const char* name = (const char*)ASN1_STRING_get0_data(gen->d.ia5);
|
||||
const char* name = reinterpret_cast<const char*>(ASN1_STRING_get0_data(gen->d.ia5));
|
||||
auto bs = make_intrusive<StringVal>(len, name);
|
||||
|
||||
switch ( gen->type ) {
|
||||
|
@ -378,7 +378,7 @@ void X509::ParseSAN(X509_EXTENSION* ext) {
|
|||
if ( ips == nullptr )
|
||||
ips = make_intrusive<VectorVal>(id::find_type<VectorType>("addr_vec"));
|
||||
|
||||
uint32_t* addr = (uint32_t*)gen->d.ip->data;
|
||||
uint32_t* addr = reinterpret_cast<uint32_t*>(gen->d.ip->data);
|
||||
|
||||
if ( gen->d.ip->length == 4 )
|
||||
ips->Assign(ips->Size(), make_intrusive<AddrVal>(*addr));
|
||||
|
|
|
@ -31,7 +31,7 @@ double X509Common::GetTimeFromAsn1(const ASN1_TIME* atime, file_analysis::File*
|
|||
char lBuffer[26];
|
||||
char* pBuffer = lBuffer;
|
||||
|
||||
const char* pString = (const char*)atime->data;
|
||||
const char* pString = reinterpret_cast<const char*>(atime->data);
|
||||
unsigned int remaining = atime->length;
|
||||
|
||||
if ( atime->type == V_ASN1_UTCTIME ) {
|
||||
|
@ -176,7 +176,7 @@ void X509Common::ParseSignedCertificateTimestamps(X509_EXTENSION* ext) {
|
|||
// the octet string of the extension contains the octet string which in turn
|
||||
// contains the SCT. Obviously.
|
||||
|
||||
unsigned char* ext_val_copy = (unsigned char*)OPENSSL_malloc(ext_val->length);
|
||||
unsigned char* ext_val_copy = reinterpret_cast<unsigned char*>(OPENSSL_malloc(ext_val->length));
|
||||
unsigned char* ext_val_second_pointer = ext_val_copy;
|
||||
memcpy(ext_val_copy, ext_val->data, ext_val->length);
|
||||
|
||||
|
@ -285,7 +285,7 @@ StringValPtr X509Common::GetExtensionFromBIO(BIO* bio, file_analysis::File* f) {
|
|||
return val_mgr->EmptyString();
|
||||
}
|
||||
|
||||
char* buffer = (char*)malloc(length);
|
||||
char* buffer = reinterpret_cast<char*>(malloc(length));
|
||||
|
||||
if ( ! buffer ) {
|
||||
// Just emit an error here and try to continue instead of aborting
|
||||
|
|
|
@ -43,7 +43,7 @@ STACK_OF(X509)* x509_get_untrusted_stack(zeek::VectorVal* certs_vec)
|
|||
continue;
|
||||
|
||||
// Fixme: check type
|
||||
X509* x = ((zeek::file_analysis::detail::X509Val*) sv.get())->GetCertificate();
|
||||
X509* x = (static_cast<zeek::file_analysis::detail::X509Val*>(sv.get()))->GetCertificate();
|
||||
if ( ! x )
|
||||
{
|
||||
sk_X509_free(untrusted_certs);
|
||||
|
@ -185,7 +185,7 @@ bool check_hostname(std::string_view hostname, std::string_view certname)
|
|||
function x509_parse%(cert: opaque of x509%): X509::Certificate
|
||||
%{
|
||||
assert(cert);
|
||||
auto* h = (zeek::file_analysis::detail::X509Val*) cert;
|
||||
auto* h = static_cast<zeek::file_analysis::detail::X509Val*>(cert);
|
||||
|
||||
return zeek::file_analysis::detail::X509::ParseCertificate(h);
|
||||
%}
|
||||
|
@ -218,7 +218,7 @@ function x509_from_der%(der: string%): opaque of x509
|
|||
function x509_get_certificate_string%(cert: opaque of x509, pem: bool &default=F%): string
|
||||
%{
|
||||
assert(cert);
|
||||
auto* h = (zeek::file_analysis::detail::X509Val*) cert;
|
||||
auto* h = static_cast<zeek::file_analysis::detail::X509Val*>(cert);
|
||||
|
||||
BIO *bio = BIO_new(BIO_s_mem());
|
||||
|
||||
|
@ -276,7 +276,7 @@ function x509_ocsp_verify%(certs: x509_opaque_vector, ocsp_reply: string, root_c
|
|||
return x509_result_record(-1, "undefined value in certificate vector");
|
||||
}
|
||||
|
||||
auto* cert_handle = (zeek::file_analysis::detail::X509Val*) sv.get();
|
||||
auto* cert_handle = static_cast<zeek::file_analysis::detail::X509Val*>(sv.get());
|
||||
|
||||
X509* cert = cert_handle->GetCertificate();
|
||||
if ( ! cert )
|
||||
|
@ -438,7 +438,7 @@ function x509_ocsp_verify%(certs: x509_opaque_vector, ocsp_reply: string, root_c
|
|||
goto x509_ocsp_cleanup;
|
||||
}
|
||||
|
||||
if ( OCSP_id_cmp(certid, (OCSP_CERTID*)OCSP_SINGLERESP_get0_id(single)) != 0 )
|
||||
if ( OCSP_id_cmp(certid, reinterpret_cast<const OCSP_CERTID*>(OCSP_SINGLERESP_get0_id(single))) != 0 )
|
||||
return x509_result_record(-1, "OCSP reply is not for host certificate");
|
||||
|
||||
// next - check freshness of proof...
|
||||
|
@ -557,7 +557,7 @@ function x509_verify%(certs: x509_opaque_vector, root_certs: table_string_of_str
|
|||
zeek::emit_builtin_error("undefined value in certificate vector");
|
||||
return x509_result_record(-1, "undefined value in certificate vector");
|
||||
}
|
||||
auto* cert_handle = (zeek::file_analysis::detail::X509Val*) sv.get();
|
||||
auto* cert_handle = static_cast<zeek::file_analysis::detail::X509Val*>(sv.get());
|
||||
|
||||
X509* cert = cert_handle->GetCertificate();
|
||||
if ( ! cert )
|
||||
|
@ -653,8 +653,8 @@ x509_verify_chainerror:
|
|||
function sct_verify%(cert: opaque of x509, logid: string, log_key: string, signature: string, timestamp: count, hash_algorithm: count, issuer_key_hash: string &default=""%): bool
|
||||
%{
|
||||
assert(cert);
|
||||
auto* h = (zeek::file_analysis::detail::X509Val*) cert;
|
||||
X509* x = ((zeek::file_analysis::detail::X509Val*) h)->GetCertificate();
|
||||
auto* h = static_cast<zeek::file_analysis::detail::X509Val*>(cert);
|
||||
X509* x = h->GetCertificate();
|
||||
|
||||
assert(sizeof(timestamp) >= 8);
|
||||
uint64_t timestamp_network = htonll(timestamp);
|
||||
|
@ -876,7 +876,7 @@ zeek::StringValPtr x509_entity_hash(zeek::file_analysis::detail::X509Val *cert_h
|
|||
## x509_verify sct_verify
|
||||
function x509_subject_name_hash%(cert: opaque of x509, hash_alg: count%): string
|
||||
%{
|
||||
auto* cert_handle = (zeek::file_analysis::detail::X509Val *) cert;
|
||||
auto* cert_handle = static_cast<zeek::file_analysis::detail::X509Val*>(cert);
|
||||
|
||||
return x509_entity_hash(cert_handle, hash_alg, 0);
|
||||
%}
|
||||
|
@ -894,7 +894,7 @@ function x509_subject_name_hash%(cert: opaque of x509, hash_alg: count%): string
|
|||
## x509_verify sct_verify
|
||||
function x509_issuer_name_hash%(cert: opaque of x509, hash_alg: count%): string
|
||||
%{
|
||||
auto* cert_handle = (zeek::file_analysis::detail::X509Val *) cert;
|
||||
auto* cert_handle = static_cast<zeek::file_analysis::detail::X509Val*>(cert);
|
||||
|
||||
return x509_entity_hash(cert_handle, hash_alg, 1);
|
||||
%}
|
||||
|
@ -912,7 +912,7 @@ function x509_issuer_name_hash%(cert: opaque of x509, hash_alg: count%): string
|
|||
## x509_verify sct_verify
|
||||
function x509_spki_hash%(cert: opaque of x509, hash_alg: count%): string
|
||||
%{
|
||||
auto* cert_handle = (zeek::file_analysis::detail::X509Val *) cert;
|
||||
auto* cert_handle = static_cast<zeek::file_analysis::detail::X509Val*>(cert);
|
||||
|
||||
return x509_entity_hash(cert_handle, hash_alg, 2);
|
||||
%}
|
||||
|
@ -996,7 +996,7 @@ function x509_check_hostname%(hostname: string, certname: string%): bool
|
|||
## .. zeek:see:: x509_check_hostname
|
||||
function x509_check_cert_hostname%(cert_opaque: opaque of x509, hostname: string%): string
|
||||
%{
|
||||
auto* cert_handle = (zeek::file_analysis::detail::X509Val *) cert_opaque;
|
||||
auto* cert_handle = static_cast<zeek::file_analysis::detail::X509Val*>(cert_opaque);
|
||||
std::string_view hostview = hostname->ToStdStringView();
|
||||
|
||||
X509* cert = cert_handle->GetCertificate();
|
||||
|
|
|
@ -41,7 +41,7 @@ struct InputHash {
|
|||
InputHash::~InputHash() { delete idxkey; }
|
||||
|
||||
static void input_hash_delete_func(void* val) {
|
||||
InputHash* h = (InputHash*)val;
|
||||
InputHash* h = reinterpret_cast<InputHash*>(val);
|
||||
delete h;
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ bool Manager::CreateStream(Stream* info, RecordVal* description) {
|
|||
// get the source ...
|
||||
auto source_val = description->GetFieldOrDefault("source");
|
||||
const String* bsource = source_val->AsString();
|
||||
string source((const char*)bsource->Bytes(), bsource->Len());
|
||||
string source(reinterpret_cast<const char*>(bsource->Bytes()), bsource->Len());
|
||||
|
||||
ReaderBackend::ReaderInfo rinfo;
|
||||
rinfo.source = util::copy_string(source.c_str(), source.size());
|
||||
|
@ -1068,7 +1068,7 @@ int Manager::SendEntryTable(Stream* i, const Value* const* vals) {
|
|||
assert(i);
|
||||
|
||||
assert(i->stream_type == TABLE_STREAM);
|
||||
TableStream* stream = (TableStream*)i;
|
||||
TableStream* stream = static_cast<TableStream*>(i);
|
||||
|
||||
zeek::detail::HashKey* idxhash = HashValues(stream->num_idx_fields, vals);
|
||||
|
||||
|
@ -1386,7 +1386,7 @@ int Manager::SendEventStreamEvent(Stream* i, EnumVal* type, const Value* const*
|
|||
assert(i);
|
||||
|
||||
assert(i->stream_type == EVENT_STREAM);
|
||||
EventStream* stream = (EventStream*)i;
|
||||
EventStream* stream = static_cast<EventStream*>(i);
|
||||
|
||||
list<Val*> out_vals;
|
||||
Ref(stream->description);
|
||||
|
@ -1440,7 +1440,7 @@ int Manager::PutTable(Stream* i, const Value* const* vals) {
|
|||
assert(i);
|
||||
|
||||
assert(i->stream_type == TABLE_STREAM);
|
||||
TableStream* stream = (TableStream*)i;
|
||||
TableStream* stream = static_cast<TableStream*>(i);
|
||||
|
||||
bool convert_error = false;
|
||||
|
||||
|
@ -1561,7 +1561,7 @@ void Manager::Clear(ReaderFrontend* reader) {
|
|||
#endif
|
||||
|
||||
assert(i->stream_type == TABLE_STREAM);
|
||||
TableStream* stream = (TableStream*)i;
|
||||
TableStream* stream = static_cast<TableStream*>(i);
|
||||
|
||||
stream->tab->RemoveAll();
|
||||
}
|
||||
|
@ -1578,7 +1578,7 @@ bool Manager::Delete(ReaderFrontend* reader, Value** vals) {
|
|||
int readVals = 0;
|
||||
|
||||
if ( i->stream_type == TABLE_STREAM ) {
|
||||
TableStream* stream = (TableStream*)i;
|
||||
TableStream* stream = static_cast<TableStream*>(i);
|
||||
bool convert_error = false;
|
||||
Val* idxval = ValueToIndexVal(i, stream->num_idx_fields, stream->itype, vals, convert_error);
|
||||
readVals = stream->num_idx_fields + stream->num_val_fields;
|
||||
|
@ -1897,12 +1897,12 @@ int Manager::CopyValue(char* data, const int startpos, const Value* val) const {
|
|||
switch ( val->val.addr_val.family ) {
|
||||
case IPv4:
|
||||
length = sizeof(val->val.addr_val.in.in4);
|
||||
memcpy(data + startpos, (const char*)&(val->val.addr_val.in.in4), length);
|
||||
memcpy(data + startpos, reinterpret_cast<const char*>(&val->val.addr_val.in.in4), length);
|
||||
break;
|
||||
|
||||
case IPv6:
|
||||
length = sizeof(val->val.addr_val.in.in6);
|
||||
memcpy(data + startpos, (const char*)&(val->val.addr_val.in.in6), length);
|
||||
memcpy(data + startpos, reinterpret_cast<const char*>(&val->val.addr_val.in.in6), length);
|
||||
break;
|
||||
|
||||
default: assert(false);
|
||||
|
@ -1916,19 +1916,19 @@ int Manager::CopyValue(char* data, const int startpos, const Value* val) const {
|
|||
switch ( val->val.subnet_val.prefix.family ) {
|
||||
case IPv4:
|
||||
length = sizeof(val->val.addr_val.in.in4);
|
||||
memcpy(data + startpos, (const char*)&(val->val.subnet_val.prefix.in.in4), length);
|
||||
memcpy(data + startpos, reinterpret_cast<const char*>(&val->val.subnet_val.prefix.in.in4), length);
|
||||
break;
|
||||
|
||||
case IPv6:
|
||||
length = sizeof(val->val.addr_val.in.in6);
|
||||
memcpy(data + startpos, (const char*)&(val->val.subnet_val.prefix.in.in6), length);
|
||||
memcpy(data + startpos, reinterpret_cast<const char*>(&val->val.subnet_val.prefix.in.in6), length);
|
||||
break;
|
||||
|
||||
default: assert(false);
|
||||
}
|
||||
|
||||
int lengthlength = sizeof(val->val.subnet_val.length);
|
||||
memcpy(data + startpos + length, (const char*)&(val->val.subnet_val.length), lengthlength);
|
||||
memcpy(data + startpos + length, reinterpret_cast<const char*>(&val->val.subnet_val.length), lengthlength);
|
||||
length += lengthlength;
|
||||
|
||||
return length;
|
||||
|
@ -2037,7 +2037,8 @@ Val* Manager::ValueToVal(const Stream* i, const Value* val, Type* request_type,
|
|||
case TYPE_INTERVAL: return new IntervalVal(val->val.double_val);
|
||||
|
||||
case TYPE_STRING: {
|
||||
String* s = new String((const u_char*)val->val.string_val.data, val->val.string_val.length, true);
|
||||
String* s =
|
||||
new String(reinterpret_cast<const u_char*>(val->val.string_val.data), val->val.string_val.length, true);
|
||||
return new StringVal(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,21 +64,22 @@ void Ascii::DoClose() { read_location.reset(); }
|
|||
bool Ascii::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fields) {
|
||||
StopWarningSuppression();
|
||||
|
||||
separator.assign((const char*)BifConst::InputAscii::separator->Bytes(), BifConst::InputAscii::separator->Len());
|
||||
separator.assign(reinterpret_cast<const char*>(BifConst::InputAscii::separator->Bytes()),
|
||||
BifConst::InputAscii::separator->Len());
|
||||
|
||||
set_separator.assign((const char*)BifConst::InputAscii::set_separator->Bytes(),
|
||||
set_separator.assign(reinterpret_cast<const char*>(BifConst::InputAscii::set_separator->Bytes()),
|
||||
BifConst::InputAscii::set_separator->Len());
|
||||
|
||||
empty_field.assign((const char*)BifConst::InputAscii::empty_field->Bytes(),
|
||||
empty_field.assign(reinterpret_cast<const char*>(BifConst::InputAscii::empty_field->Bytes()),
|
||||
BifConst::InputAscii::empty_field->Len());
|
||||
|
||||
unset_field.assign((const char*)BifConst::InputAscii::unset_field->Bytes(),
|
||||
unset_field.assign(reinterpret_cast<const char*>(BifConst::InputAscii::unset_field->Bytes()),
|
||||
BifConst::InputAscii::unset_field->Len());
|
||||
|
||||
fail_on_invalid_lines = BifConst::InputAscii::fail_on_invalid_lines;
|
||||
fail_on_file_problem = BifConst::InputAscii::fail_on_file_problem;
|
||||
|
||||
path_prefix.assign((const char*)BifConst::InputAscii::path_prefix->Bytes(),
|
||||
path_prefix.assign(reinterpret_cast<const char*>(BifConst::InputAscii::path_prefix->Bytes()),
|
||||
BifConst::InputAscii::path_prefix->Len());
|
||||
|
||||
// Set per-filter configuration options.
|
||||
|
|
|
@ -69,7 +69,7 @@ bool Binary::DoInit(const ReaderInfo& info, int num_fields, const Field* const*
|
|||
ino = 0;
|
||||
firstrun = true;
|
||||
|
||||
path_prefix.assign((const char*)BifConst::InputBinary::path_prefix->Bytes(),
|
||||
path_prefix.assign(reinterpret_cast<const char*>(BifConst::InputBinary::path_prefix->Bytes()),
|
||||
BifConst::InputBinary::path_prefix->Len());
|
||||
|
||||
if ( ! info.source || strlen(info.source) == 0 ) {
|
||||
|
|
|
@ -54,10 +54,10 @@ void Config::DoClose() {}
|
|||
bool Config::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fields) {
|
||||
fail_on_file_problem = BifConst::InputConfig::fail_on_file_problem;
|
||||
|
||||
set_separator.assign((const char*)BifConst::InputConfig::set_separator->Bytes(),
|
||||
set_separator.assign(reinterpret_cast<const char*>(BifConst::InputConfig::set_separator->Bytes()),
|
||||
BifConst::InputConfig::set_separator->Len());
|
||||
|
||||
empty_field.assign((const char*)BifConst::InputConfig::empty_field->Bytes(),
|
||||
empty_field.assign(reinterpret_cast<const char*>(BifConst::InputConfig::empty_field->Bytes()),
|
||||
BifConst::InputConfig::empty_field->Len());
|
||||
|
||||
threading::formatter::Ascii::SeparatorInfo sep_info("\t", set_separator, "", empty_field);
|
||||
|
|
|
@ -41,7 +41,7 @@ Raw::Raw(ReaderFrontend* frontend) : ReaderBackend(frontend), file(nullptr, fclo
|
|||
dev = 0;
|
||||
forcekill = false;
|
||||
offset = 0;
|
||||
separator.assign((const char*)BifConst::InputRaw::record_separator->Bytes(),
|
||||
separator.assign(reinterpret_cast<const char*>(BifConst::InputRaw::record_separator->Bytes()),
|
||||
BifConst::InputRaw::record_separator->Len());
|
||||
|
||||
sep_length = BifConst::InputRaw::record_separator->Len();
|
||||
|
|
|
@ -17,13 +17,13 @@ using zeek::threading::Value;
|
|||
namespace zeek::input::reader::detail {
|
||||
|
||||
SQLite::SQLite(ReaderFrontend* frontend) : ReaderBackend(frontend) {
|
||||
set_separator.assign((const char*)BifConst::LogSQLite::set_separator->Bytes(),
|
||||
set_separator.assign(reinterpret_cast<const char*>(BifConst::LogSQLite::set_separator->Bytes()),
|
||||
BifConst::InputSQLite::set_separator->Len());
|
||||
|
||||
unset_field.assign((const char*)BifConst::LogSQLite::unset_field->Bytes(),
|
||||
unset_field.assign(reinterpret_cast<const char*>(BifConst::LogSQLite::unset_field->Bytes()),
|
||||
BifConst::InputSQLite::unset_field->Len());
|
||||
|
||||
empty_field.assign((const char*)BifConst::LogAscii::empty_field->Bytes(),
|
||||
empty_field.assign(reinterpret_cast<const char*>(BifConst::LogAscii::empty_field->Bytes()),
|
||||
BifConst::InputSQLite::empty_field->Len());
|
||||
|
||||
io = new threading::formatter::Ascii(this, threading::formatter::Ascii::SeparatorInfo(std::string(), set_separator,
|
||||
|
@ -107,7 +107,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt* st, const threading::Field* field, int p
|
|||
switch ( field->type ) {
|
||||
case TYPE_ENUM:
|
||||
case TYPE_STRING: {
|
||||
const char* text = (const char*)sqlite3_column_text(st, pos);
|
||||
const char* text = reinterpret_cast<const char*>(sqlite3_column_text(st, pos));
|
||||
int length = sqlite3_column_bytes(st, pos);
|
||||
|
||||
char* out = new char[length];
|
||||
|
@ -149,7 +149,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt* st, const threading::Field* field, int p
|
|||
val->val.port_val.port = sqlite3_column_int(st, pos);
|
||||
val->val.port_val.proto = TRANSPORT_UNKNOWN;
|
||||
if ( subpos != -1 ) {
|
||||
const char* text = (const char*)sqlite3_column_text(st, subpos);
|
||||
const char* text = reinterpret_cast<const char*>(sqlite3_column_text(st, subpos));
|
||||
|
||||
if ( text == nullptr )
|
||||
Error("Port protocol definition did not contain text");
|
||||
|
@ -162,7 +162,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt* st, const threading::Field* field, int p
|
|||
}
|
||||
|
||||
case TYPE_SUBNET: {
|
||||
const char* text = (const char*)sqlite3_column_text(st, pos);
|
||||
const char* text = reinterpret_cast<const char*>(sqlite3_column_text(st, pos));
|
||||
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||
size_t slash_pos = s.find('/');
|
||||
int width = atoi(s.substr(slash_pos + 1).c_str());
|
||||
|
@ -174,7 +174,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt* st, const threading::Field* field, int p
|
|||
}
|
||||
|
||||
case TYPE_ADDR: {
|
||||
const char* text = (const char*)sqlite3_column_text(st, pos);
|
||||
const char* text = reinterpret_cast<const char*>(sqlite3_column_text(st, pos));
|
||||
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||
val->val.addr_val = io->ParseAddr(s);
|
||||
break;
|
||||
|
@ -182,7 +182,7 @@ Value* SQLite::EntryToVal(sqlite3_stmt* st, const threading::Field* field, int p
|
|||
|
||||
case TYPE_TABLE:
|
||||
case TYPE_VECTOR: {
|
||||
const char* text = (const char*)sqlite3_column_text(st, pos);
|
||||
const char* text = reinterpret_cast<const char*>(sqlite3_column_text(st, pos));
|
||||
std::string s(text, sqlite3_column_bytes(st, pos));
|
||||
delete val;
|
||||
val = io->ParseValue(s, "", field->type, field->subtype);
|
||||
|
|
|
@ -77,7 +77,7 @@ bool BPF_Program::Compile(pcap_t* pcap, const char* filter, uint32_t netmask, bo
|
|||
|
||||
FreeCode();
|
||||
|
||||
if ( pcap_compile(pcap, &m_program, (char*)filter, optimize, netmask) < 0 ) {
|
||||
if ( pcap_compile(pcap, &m_program, const_cast<char*>(filter), optimize, netmask) < 0 ) {
|
||||
state_message = std::string(pcap_geterr(pcap));
|
||||
state = GetStateFromMessage(state_message);
|
||||
return false;
|
||||
|
|
|
@ -165,7 +165,7 @@ RecordValPtr Packet::ToVal(const Packet* p) {
|
|||
val->Assign(1, static_cast<uint32_t>(p->ts.tv_usec));
|
||||
val->Assign(2, p->cap_len);
|
||||
val->Assign(3, p->len);
|
||||
val->Assign(4, zeek::make_intrusive<zeek::StringVal>(p->cap_len, (const char*)p->data));
|
||||
val->Assign(4, zeek::make_intrusive<zeek::StringVal>(p->cap_len, reinterpret_cast<const char*>(p->data)));
|
||||
val->Assign(5, zeek::BifType::Enum::link_encap->GetEnumVal(p->link_type));
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -137,7 +137,7 @@ bool AF_PacketSource::BindInterface(const AF_PacketSource::InterfaceInfo& info)
|
|||
saddr_ll.sll_protocol = htons(ETH_P_ALL);
|
||||
saddr_ll.sll_ifindex = info.index;
|
||||
|
||||
ret = bind(socket_fd, (struct sockaddr*)&saddr_ll, sizeof(saddr_ll));
|
||||
ret = bind(socket_fd, reinterpret_cast<struct sockaddr*>(&saddr_ll), sizeof(saddr_ll));
|
||||
return (ret >= 0);
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ bool AF_PacketSource::ExtractNextPacket(zeek::Packet* pkt) {
|
|||
current_hdr.ts.tv_usec = packet->tp_nsec / 1000;
|
||||
current_hdr.caplen = packet->tp_snaplen;
|
||||
current_hdr.len = packet->tp_len;
|
||||
data = (u_char*)packet + packet->tp_mac;
|
||||
data = reinterpret_cast<u_char*>(packet) + packet->tp_mac;
|
||||
|
||||
if ( ! ApplyBPFFilter(current_filter, ¤t_hdr, data) ) {
|
||||
++num_discarded;
|
||||
|
|
|
@ -24,12 +24,12 @@ RX_Ring::RX_Ring(int sock, size_t bufsize, size_t blocksize, int blocktimeout_ms
|
|||
throw RX_RingException("unable to set TPacket version");
|
||||
|
||||
InitLayout(bufsize, blocksize, blocktimeout_msec);
|
||||
if ( setsockopt(sock, SOL_PACKET, PACKET_RX_RING, (uint8_t*)&layout, sizeof(layout)) != 0 )
|
||||
if ( setsockopt(sock, SOL_PACKET, PACKET_RX_RING, reinterpret_cast<uint8_t*>(&layout), sizeof(layout)) != 0 )
|
||||
throw RX_RingException("unable to set ring layout");
|
||||
|
||||
// Map memory
|
||||
size = static_cast<size_t>(layout.tp_block_size) * layout.tp_block_nr;
|
||||
ring = (uint8_t*)mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, sock, 0);
|
||||
ring = reinterpret_cast<uint8_t*>(mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, sock, 0));
|
||||
if ( ring == MAP_FAILED )
|
||||
throw RX_RingException("unable to map ring memory");
|
||||
|
||||
|
@ -39,7 +39,7 @@ RX_Ring::RX_Ring(int sock, size_t bufsize, size_t blocksize, int blocktimeout_ms
|
|||
// Init block mapping
|
||||
blocks = new tpacket_block_desc*[layout.tp_block_nr];
|
||||
for ( size_t i = 0; i < layout.tp_block_nr; i++ )
|
||||
blocks[i] = (struct tpacket_block_desc*)(ring + i * layout.tp_block_size);
|
||||
blocks[i] = reinterpret_cast<tpacket_block_desc*>(ring + i * layout.tp_block_size);
|
||||
}
|
||||
|
||||
RX_Ring::~RX_Ring() {
|
||||
|
@ -65,11 +65,12 @@ bool RX_Ring::GetNextPacket(tpacket3_hdr** hdr) {
|
|||
NextBlock();
|
||||
return false;
|
||||
}
|
||||
packet = (struct tpacket3_hdr*)((uint8_t*)blocks[block_num] + block_hdr->offset_to_first_pkt);
|
||||
packet = reinterpret_cast<tpacket3_hdr*>(reinterpret_cast<uint8_t*>(blocks[block_num]) +
|
||||
block_hdr->offset_to_first_pkt);
|
||||
}
|
||||
else
|
||||
// Continue with block
|
||||
packet = (struct tpacket3_hdr*)((uint8_t*)packet + packet->tp_next_offset);
|
||||
packet = reinterpret_cast<tpacket3_hdr*>(reinterpret_cast<uint8_t*>(packet) + packet->tp_next_offset);
|
||||
|
||||
*hdr = packet;
|
||||
packet_num--;
|
||||
|
|
|
@ -94,7 +94,7 @@ bool PcapDumper::Dump(const Packet* pkt) {
|
|||
// Reconstitute the pcap_pkthdr.
|
||||
const struct pcap_pkthdr phdr = {pkt->ts, pkt->cap_len, pkt->len};
|
||||
|
||||
pcap_dump((u_char*)dumper, &phdr, pkt->data);
|
||||
pcap_dump(reinterpret_cast<u_char*>(dumper), &phdr, pkt->data);
|
||||
pcap_dump_flush(dumper);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -847,7 +847,7 @@ bool Manager::TraverseRecord(Stream* stream, Filter* filter, RecordType* rt, Tab
|
|||
}
|
||||
|
||||
++filter->num_fields;
|
||||
filter->fields = (threading::Field**)tmp;
|
||||
filter->fields = reinterpret_cast<threading::Field**>(tmp);
|
||||
|
||||
TypeTag st = TYPE_VOID;
|
||||
|
||||
|
|
|
@ -229,21 +229,25 @@ void Ascii::InitConfigOptions() {
|
|||
enable_utf_8 = BifConst::LogAscii::enable_utf_8;
|
||||
gzip_level = BifConst::LogAscii::gzip_level;
|
||||
|
||||
separator.assign((const char*)BifConst::LogAscii::separator->Bytes(), BifConst::LogAscii::separator->Len());
|
||||
separator.assign(reinterpret_cast<const char*>(BifConst::LogAscii::separator->Bytes()),
|
||||
BifConst::LogAscii::separator->Len());
|
||||
|
||||
set_separator.assign((const char*)BifConst::LogAscii::set_separator->Bytes(),
|
||||
set_separator.assign(reinterpret_cast<const char*>(BifConst::LogAscii::set_separator->Bytes()),
|
||||
BifConst::LogAscii::set_separator->Len());
|
||||
|
||||
empty_field.assign((const char*)BifConst::LogAscii::empty_field->Bytes(), BifConst::LogAscii::empty_field->Len());
|
||||
empty_field.assign(reinterpret_cast<const char*>(BifConst::LogAscii::empty_field->Bytes()),
|
||||
BifConst::LogAscii::empty_field->Len());
|
||||
|
||||
unset_field.assign((const char*)BifConst::LogAscii::unset_field->Bytes(), BifConst::LogAscii::unset_field->Len());
|
||||
unset_field.assign(reinterpret_cast<const char*>(BifConst::LogAscii::unset_field->Bytes()),
|
||||
BifConst::LogAscii::unset_field->Len());
|
||||
|
||||
meta_prefix.assign((const char*)BifConst::LogAscii::meta_prefix->Bytes(), BifConst::LogAscii::meta_prefix->Len());
|
||||
meta_prefix.assign(reinterpret_cast<const char*>(BifConst::LogAscii::meta_prefix->Bytes()),
|
||||
BifConst::LogAscii::meta_prefix->Len());
|
||||
|
||||
json_timestamps = zeek::obj_desc_short(BifConst::LogAscii::json_timestamps);
|
||||
json_include_unset_fields = BifConst::LogAscii::json_include_unset_fields;
|
||||
|
||||
gzip_file_extension.assign((const char*)BifConst::LogAscii::gzip_file_extension->Bytes(),
|
||||
gzip_file_extension.assign(reinterpret_cast<const char*>(BifConst::LogAscii::gzip_file_extension->Bytes()),
|
||||
BifConst::LogAscii::gzip_file_extension->Len());
|
||||
|
||||
logdir = zeek::id::find_const<StringVal>("Log::default_logdir")->ToStdString();
|
||||
|
@ -587,7 +591,7 @@ bool Ascii::DoWrite(int num_fields, const threading::Field* const* fields, threa
|
|||
|
||||
desc.AddRaw("\n", 1);
|
||||
|
||||
const char* bytes = (const char*)desc.Bytes();
|
||||
const char* bytes = reinterpret_cast<const char*>(desc.Bytes());
|
||||
size_t len = desc.Size();
|
||||
|
||||
if ( strncmp(bytes, meta_prefix.data(), meta_prefix.size()) == 0 ) {
|
||||
|
|
|
@ -18,12 +18,14 @@ using zeek::threading::Value;
|
|||
namespace zeek::logging::writer::detail {
|
||||
|
||||
SQLite::SQLite(WriterFrontend* frontend) : WriterBackend(frontend, /*send_heartbeats=*/false) {
|
||||
set_separator.assign((const char*)BifConst::LogSQLite::set_separator->Bytes(),
|
||||
set_separator.assign(reinterpret_cast<const char*>(BifConst::LogSQLite::set_separator->Bytes()),
|
||||
BifConst::LogSQLite::set_separator->Len());
|
||||
|
||||
unset_field.assign((const char*)BifConst::LogSQLite::unset_field->Bytes(), BifConst::LogSQLite::unset_field->Len());
|
||||
unset_field.assign(reinterpret_cast<const char*>(BifConst::LogSQLite::unset_field->Bytes()),
|
||||
BifConst::LogSQLite::unset_field->Len());
|
||||
|
||||
empty_field.assign((const char*)BifConst::LogSQLite::empty_field->Bytes(), BifConst::LogSQLite::empty_field->Len());
|
||||
empty_field.assign(reinterpret_cast<const char*>(BifConst::LogSQLite::empty_field->Bytes()),
|
||||
BifConst::LogSQLite::empty_field->Len());
|
||||
|
||||
synchronous = BifConst::LogSQLite::synchronous->AsInt();
|
||||
journal_mode = BifConst::LogSQLite::journal_mode->AsInt();
|
||||
|
@ -272,11 +274,13 @@ int SQLite::AddParams(Value* val, int pos) {
|
|||
|
||||
case TYPE_SUBNET: {
|
||||
string out = io->Render(val->val.subnet_val);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
return sqlite3_bind_text(st, pos, out.data(), out.size(), SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
case TYPE_ADDR: {
|
||||
string out = io->Render(val->val.addr_val);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
return sqlite3_bind_text(st, pos, out.data(), out.size(), SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
|
@ -291,6 +295,7 @@ int SQLite::AddParams(Value* val, int pos) {
|
|||
if ( ! val->val.string_val.length || val->val.string_val.length == 0 )
|
||||
return sqlite3_bind_null(st, pos);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
return sqlite3_bind_text(st, pos, val->val.string_val.data, val->val.string_val.length, SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
|
@ -311,7 +316,9 @@ int SQLite::AddParams(Value* val, int pos) {
|
|||
}
|
||||
|
||||
desc.RemoveEscapeSequence(set_separator);
|
||||
return sqlite3_bind_text(st, pos, (const char*)desc.Bytes(), desc.Size(), SQLITE_TRANSIENT);
|
||||
return sqlite3_bind_text(st, pos, reinterpret_cast<const char*>(desc.Bytes()), desc.Size(),
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
case TYPE_VECTOR: {
|
||||
|
@ -331,7 +338,9 @@ int SQLite::AddParams(Value* val, int pos) {
|
|||
}
|
||||
|
||||
desc.RemoveEscapeSequence(set_separator);
|
||||
return sqlite3_bind_text(st, pos, (const char*)desc.Bytes(), desc.Size(), SQLITE_TRANSIENT);
|
||||
return sqlite3_bind_text(st, pos, reinterpret_cast<const char*>(desc.Bytes()), desc.Size(),
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
|
||||
SQLITE_TRANSIENT);
|
||||
}
|
||||
|
||||
default: Error(Fmt("unsupported field format %d", val->type)); return 0;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue