net/addr/ip: Verify null-terminated strings
Change-Id: I7d5e0a5b06b1cf1305de6f2d1aecc322f6182ed9
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/include/stdplus/net/addr/ip.hpp b/include/stdplus/net/addr/ip.hpp
index 50fe64c..0323e7d 100644
--- a/include/stdplus/net/addr/ip.hpp
+++ b/include/stdplus/net/addr/ip.hpp
@@ -494,9 +494,12 @@
struct CompileInAddr : CompileInAddrInt<Addr>
{
CharT str[N - 1];
+ static inline void notNullTerminated() {}
constexpr CompileInAddr(const CharT (&str)[N]) noexcept
{
+ if (str[N - 1] != '\0')
+ notNullTerminated();
std::copy(str, str + N - 1, this->str);
this->compile(std::basic_string_view{this->str, N - 1});
}