aboutsummaryrefslogtreecommitdiff
path: root/src/net/i2p_address.cpp
diff options
context:
space:
mode:
authortobtoht <tob@featherwallet.org>2026-06-09 17:49:35 +0000
committertobtoht <tob@featherwallet.org>2026-06-09 17:49:35 +0000
commit1ed6b8183c798fe65df724d6ea7fdc3ba3ad20f7 (patch)
treea7d0176fb663a0c1211ea55eed52b42e0c5d9a6c /src/net/i2p_address.cpp
parentf6939487fe5f8efe865cbfa9204956c85411241b (diff)
parent93d792e63c85baec6f8a3b8f9bbad3f803dd3a7e (diff)
downloadmonzero-core-1ed6b8183c798fe65df724d6ea7fdc3ba3ad20f7.tar.gz
monzero-core-1ed6b8183c798fe65df724d6ea7fdc3ba3ad20f7.tar.xz
monzero-core-1ed6b8183c798fe65df724d6ea7fdc3ba3ad20f7.zip
Merge pull request #10704
93d792e net: canonicalize Tor/I2P hosts during deserialization (selsta)
Diffstat (limited to 'src/net/i2p_address.cpp')
-rw-r--r--src/net/i2p_address.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/net/i2p_address.cpp b/src/net/i2p_address.cpp
index e793048c0..e24e7da01 100644
--- a/src/net/i2p_address.cpp
+++ b/src/net/i2p_address.cpp
@@ -117,11 +117,15 @@ namespace net
bool i2p_address::_load(epee::serialization::portable_storage& src, epee::serialization::section* hparent)
{
i2p_serialized in{};
- if (in._load(src, hparent) && in.host.size() < sizeof(host_) && (in.host == unknown_host || !host_check(in.host).has_error()))
+ if (in._load(src, hparent) && in.host.size() < sizeof(host_))
{
- std::memcpy(host_, in.host.data(), in.host.size());
- std::memset(host_ + in.host.size(), 0, sizeof(host_) - in.host.size());
- return true;
+ net::canonicalize_host(in.host);
+ if (in.host == unknown_host || !host_check(in.host).has_error())
+ {
+ std::memcpy(host_, in.host.data(), in.host.size());
+ std::memset(host_ + in.host.size(), 0, sizeof(host_) - in.host.size());
+ return true;
+ }
}
static_assert(sizeof(unknown_host) <= sizeof(host_), "bad buffer size");
std::memcpy(host_, unknown_host, sizeof(unknown_host)); // include null terminator