mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-02-02 06:54:15 +00:00
check if field is incomplete
This commit is contained in:
parent
ed874fe3ea
commit
75065f29f7
@ -183,6 +183,7 @@ namespace data
|
|||||||
s.seekg (1, std::ios_base::cur); r++; // =
|
s.seekg (1, std::ios_base::cur); r++; // =
|
||||||
r += ReadString (value, 255, s);
|
r += ReadString (value, 255, s);
|
||||||
s.seekg (1, std::ios_base::cur); r++; // ;
|
s.seekg (1, std::ios_base::cur); r++; // ;
|
||||||
|
if (!s) return;
|
||||||
if (!strcmp (key, "host"))
|
if (!strcmp (key, "host"))
|
||||||
{
|
{
|
||||||
boost::system::error_code ecode;
|
boost::system::error_code ecode;
|
||||||
@ -224,6 +225,11 @@ namespace data
|
|||||||
size_t l = strlen(key);
|
size_t l = strlen(key);
|
||||||
unsigned char index = key[l-1] - '0'; // TODO:
|
unsigned char index = key[l-1] - '0'; // TODO:
|
||||||
key[l-1] = 0;
|
key[l-1] = 0;
|
||||||
|
if (index > 9)
|
||||||
|
{
|
||||||
|
LogPrint (eLogError, "RouterInfo: Unexpected introducer's index ", index, " skipped");
|
||||||
|
if (s) continue; else return;
|
||||||
|
}
|
||||||
if (index >= address.introducers.size ())
|
if (index >= address.introducers.size ())
|
||||||
address.introducers.resize (index + 1);
|
address.introducers.resize (index + 1);
|
||||||
Introducer& introducer = address.introducers.at (index);
|
Introducer& introducer = address.introducers.at (index);
|
||||||
@ -263,6 +269,7 @@ namespace data
|
|||||||
s.seekg (1, std::ios_base::cur); r++; // =
|
s.seekg (1, std::ios_base::cur); r++; // =
|
||||||
r += ReadString (value, 255, s);
|
r += ReadString (value, 255, s);
|
||||||
s.seekg (1, std::ios_base::cur); r++; // ;
|
s.seekg (1, std::ios_base::cur); r++; // ;
|
||||||
|
if (!s) return;
|
||||||
m_Properties[key] = value;
|
m_Properties[key] = value;
|
||||||
|
|
||||||
// extract caps
|
// extract caps
|
||||||
@ -271,7 +278,7 @@ namespace data
|
|||||||
// check netId
|
// check netId
|
||||||
else if (!strcmp (key, ROUTER_INFO_PROPERTY_NETID) && atoi (value) != I2PD_NET_ID)
|
else if (!strcmp (key, ROUTER_INFO_PROPERTY_NETID) && atoi (value) != I2PD_NET_ID)
|
||||||
{
|
{
|
||||||
LogPrint (eLogError, "Unexpected ", ROUTER_INFO_PROPERTY_NETID, "=", value);
|
LogPrint (eLogError, "RouterInfo: Unexpected ", ROUTER_INFO_PROPERTY_NETID, "=", value);
|
||||||
m_IsUnreachable = true;
|
m_IsUnreachable = true;
|
||||||
}
|
}
|
||||||
// family
|
// family
|
||||||
@ -544,6 +551,7 @@ namespace data
|
|||||||
if (l < len)
|
if (l < len)
|
||||||
{
|
{
|
||||||
s.read (str, l);
|
s.read (str, l);
|
||||||
|
if (!s) l = 0; // failed, return empty string
|
||||||
str[l] = 0;
|
str[l] = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user