Valgrind complains with inet_pton()
when running the following program:
#include <stdio.h>
#include <arpa/inet.h>
int main()
{
struct in6_addr addr;
if (inet_pton(AF_INET6, "fe80::a00:27ff:fe80:e79", &addr) == 1) {
printf("Valid IP address.\n");
} else {
printf("Invalid IP address.\n");
}
return 0;
}
Output: Valid IP address.
Valgrind gives the following error:
==3903== Source and destination overlap in memcpy_chk(0x1ffefffe08, 0x1ffefffe02, 8)
==3903== at 0x4851042: __memcpy_chk (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==3903== by 0x49B29CC: memmove (string_fortified.h:36)
==3903== by 0x49B29CC: inet_pton6 (inet_pton.c:226)
==3903== by 0x49B29CC: __inet_pton_length (inet_pton.c:56)
==3903== by 0x49B29CC: inet_pton (inet_pton.c:69)
==3903== by 0x1091BE: main (in /home/user/inet_pton)
Valgrid version: valgrind-3.21.0
Gcc version: 13.2.0-4ubuntu3
What might be the reason?
There is a bug in Valgrind: bugs.kde.org/show_bug.cgi?id=402833
You can suppress the error with following definition:
{
memmove-overlap
Memcheck:Overlap
fun:__memcpy_chk
fun:memmove
}