From 7397bd615f1f862374e46aa7de15b0b895558eb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <> Date: Mon, 24 Mar 2025 23:37:07 -0400 Subject: [PATCH] infohash: always write end of string terminator --- include/opendht/infohash.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/opendht/infohash.h b/include/opendht/infohash.h index a880ae80..a6fcede5 100644 --- a/include/opendht/infohash.h +++ b/include/opendht/infohash.h @@ -380,10 +380,11 @@ Hash<N>::to_c_str() const { alignas(std::max_align_t) thread_local std::array<char, N*2+1> buf; for (size_t i=0; i<N; i++) { - auto b = buf.data()+i*2; + auto b = buf.data() + i*2; const auto& m = hex_map[data_[i]]; *((uint16_t*)b) = *((uint16_t*)&m); } + buf[N*2] = '\0'; return buf.data(); } -- GitLab