--- a/ping.c +++ b/ping.c @@ -913,7 +913,7 @@ struct hostent result; buf = malloc(len*sizeof(char)); - memset(buf, 0, sizeof(buf)); + memset(buf, 0, len*sizeof(char)); while (1) { hostinfo = gethostbyname_r(hostname, &result, buf, len, &h_errno);