You can change the address of strncpy
source:
while ( (len=read(clntSocket, line, MAXBUF)) != 0)
{
msg = (char *)calloc(len -3, 1); // calloc instead of malloc + memset
strncpy(msg, line+4, len);
}
}
PS: I assumed that line is char*
.