summaryrefslogtreecommitdiffstats
path: root/client-msg.c
diff options
context:
space:
mode:
Diffstat (limited to 'client-msg.c')
-rw-r--r--client-msg.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/client-msg.c b/client-msg.c
index 5a95ff62..845f10b0 100644
--- a/client-msg.c
+++ b/client-msg.c
@@ -70,16 +70,15 @@ client_msg_dispatch(struct client_ctx *cctx)
int
client_msg_fn_error(struct hdr *hdr, struct client_ctx *cctx)
{
- char *errstr;
+ struct msg_print_data data;
- if (hdr->size == SIZE_MAX)
- fatalx("bad MSG_ERROR size");
+ if (hdr->size < sizeof data)
+ fatalx("bad MSG_PRINT size");
+ buffer_read(cctx->srv_in, &data, sizeof data);
- errstr = xmalloc(hdr->size + 1);
- buffer_read(cctx->srv_in, errstr, hdr->size);
- errstr[hdr->size] = '\0';
+ data.msg[(sizeof data.msg) - 1] = '\0';
+ cctx->errstr = xstrdup(data.msg);
- cctx->errstr = errstr;
return (-1);
}