ASSERT_EQ(0, inet_aton("1.2.3.4.5", nullptr)); // Too many dots.
ASSERT_EQ(0, inet_aton("1.2.3.4.", nullptr)); // Trailing dot.
// Out of range a.b.c.d form.
ASSERT_EQ(0, inet_aton("999.0.0.1", nullptr));
ASSERT_EQ(0, inet_aton("0.999.0.1", nullptr));
ASSERT_EQ(0, inet_aton("0.0.999.1", nullptr));
ASSERT_EQ(0, inet_aton("0.0.0.999", nullptr));
// Out of range a.b.c form.
ASSERT_EQ(0, inet_aton("256.0.0", nullptr));
ASSERT_EQ(0, inet_aton("0.256.0", nullptr));
ASSERT_EQ(0, inet_aton("0.0.0x10000", nullptr));
// Out of range a.b form.
ASSERT_EQ(0, inet_aton("256.0", nullptr));
ASSERT_EQ(0, inet_aton("0.0x1000000", nullptr));
// Out of range a form.
ASSERT_EQ(0, inet_aton("0x100000000", nullptr));
TEST(arpa_inet, inet_ntop_overflow) { // OpenBSD's inet_ntop had a bug where passing a 'size' larger than INET_ADDRSTRLEN // for AF_INET or INET6_ADDRSTRLEN for AF_INET6 would cause inet_ntop to overflow an // internal buffer.
TEST(arpa_inet, inet_nsap_addr) { #if !defined(ANDROID_HOST_MUSL) // inet_nsap_addr() doesn't seem to be documented anywhere, but it's basically // text to binary for arbitrarily-long strings like "0xdeadbeef". Any // '.', '+', or '/' characters are ignored as punctuation. The return value is // the length in bytes, or 0 for all errors.
u_char buf[32];
TEST(arpa_inet, inet_nsap_ntoa) { #if !defined(ANDROID_HOST_MUSL) // inet_nsap_ntoa() doesn't seem to be documented anywhere, but it's basically // binary to text for arbitrarily-long byte buffers. // The return value is a pointer to the buffer. No errors are possible. constunsignedchar bytes[] = {0x01, 0x00, 0x02, 0x0e, 0xf0, 0x20}; char dst[32];
ASSERT_EQ(dst, inet_nsap_ntoa(6, bytes, dst));
ASSERT_STREQ(dst, "0x01.0002.0EF0.20"); #else
GTEST_SKIP() << "musl doesn't have inet_nsap_ntoa"; #endif
}
TEST(arpa_inet, inet_nsap_ntoa__nullptr) { #if !defined(ANDROID_HOST_MUSL) // If you don't provide a destination, a static buffer is provided for you. constunsignedchar bytes[] = {0x01, 0x00, 0x02, 0x0e, 0xf0, 0x20};
ASSERT_STREQ("0x01.0002.0EF0.20", inet_nsap_ntoa(6, bytes, nullptr)); #else
GTEST_SKIP() << "musl doesn't have inet_nsap_ntoa"; #endif
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.23 Sekunden
(vorverarbeitet am 2026-06-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.