Protect against possibly unterminated strings in IPC.

Fix Coverity Scan CID #60565.  The received string in `buf`
may not be NUL terminated.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>