mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix IPAddr/IPPrefix serialization bugs. (all unit tests pass)
This commit is contained in:
parent
c227563baf
commit
06e59e1398
3 changed files with 8 additions and 9 deletions
|
@ -104,7 +104,7 @@ string IPAddr::AsString() const
|
|||
char s[INET6_ADDRSTRLEN];
|
||||
|
||||
if ( inet_ntop(AF_INET6, in6.s6_addr, s, INET6_ADDRSTRLEN) == NULL )
|
||||
return "<bad IPv64 address conversion";
|
||||
return "<bad IPv6 address conversion";
|
||||
else
|
||||
return s;
|
||||
}
|
||||
|
|
|
@ -411,8 +411,8 @@ public:
|
|||
{
|
||||
// No self-assignment check here because it's correct without it and
|
||||
// makes the common case faster.
|
||||
prefix = other.Prefix();
|
||||
length = other.Length();
|
||||
prefix = other.prefix;
|
||||
length = other.length;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
@ -243,11 +243,10 @@ bool BinarySerializationFormat::Read(IPAddr* addr, const char* tag)
|
|||
|
||||
for ( int i = 0; i < n; ++i )
|
||||
{
|
||||
uint32_t i = 0;
|
||||
if ( ! Read(&i, "addr-part") )
|
||||
if ( ! Read(&raw[i], "addr-part") )
|
||||
return false;
|
||||
|
||||
raw[n] = htonl(i);
|
||||
raw[i] = htonl(raw[i]);
|
||||
}
|
||||
|
||||
if ( n == 1 )
|
||||
|
@ -260,13 +259,13 @@ bool BinarySerializationFormat::Read(IPAddr* addr, const char* tag)
|
|||
|
||||
bool BinarySerializationFormat::Read(IPPrefix* prefix, const char* tag)
|
||||
{
|
||||
string s;
|
||||
IPAddr addr;
|
||||
int len;
|
||||
|
||||
if ( ! (Read(&s, tag) && Read(&len, tag)) )
|
||||
if ( ! (Read(&addr, "prefix") && Read(&len, "width")) )
|
||||
return false;
|
||||
|
||||
*prefix = IPPrefix(IPAddr(s), len);
|
||||
*prefix = IPPrefix(addr, len);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue