Fix potential buffer overflow

Add `length` argument to `client_recv`, use `strncpy` instead of `strcpy`.