diff --git a/src/Common/formatIPv6.h b/src/Common/formatIPv6.h index c66f64cf8fd..60ada577ac8 100644 --- a/src/Common/formatIPv6.h +++ b/src/Common/formatIPv6.h @@ -88,7 +88,7 @@ inline bool parseIPv4(T * &src, EOFfunction eof, unsigned char * dst, int32_t fi /// returns pointer to the right after parsed sequence or null on failed parsing inline const char * parseIPv4(const char * src, const char * end, unsigned char * dst) { - if (parseIPv4(src, [&src, end](){ return src == end; }, dst)) + if (parseIPv4(src, [&src, end](){ return src == end || *src == '\0'; }, dst)) return src; return nullptr; } @@ -96,7 +96,8 @@ inline const char * parseIPv4(const char * src, const char * end, unsigned char /// returns true if whole buffer was parsed successfully inline bool parseIPv4whole(const char * src, const char * end, unsigned char * dst) { - return parseIPv4(src, end, dst) == reinterpret_cast(dst); + const char * parsed = parseIPv4(src, end, dst); + return parsed-end == 0; } /// returns pointer to the right after parsed sequence or null on failed parsing diff --git a/tests/queries/0_stateless/00725_ipv4_ipv6_domains.reference b/tests/queries/0_stateless/00725_ipv4_ipv6_domains.reference index 48e5f87d17f..171b0cf5a07 100644 --- a/tests/queries/0_stateless/00725_ipv4_ipv6_domains.reference +++ b/tests/queries/0_stateless/00725_ipv4_ipv6_domains.reference @@ -31,8 +31,8 @@ ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 127.0.0.1 is ipv4 string: 1 8.8.8.8 is ipv4 string: 1 hello is ipv4 string: 0 -192.168.1.1\0000 is ipv4 string: 0 -192.168.1.1\00dc is ipv4 string: 0 +192.168.1.1\0000 is ipv4 string: 0 +192.168.1.1\00dc is ipv4 string: 0 0:0:0:0:0:0:0:0 is ipv4 string: 0 0000:0000:0000:0000:0000:FFFF:C1FC:110A is ipv4 string: 0 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF is ipv4 string: 0