From 98ee12e64ee107f4cfad4f799f63e8b69878554f Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 27 Feb 2020 16:51:41 +0000 Subject: [PATCH] Use stream_read() to read all 12 bytes of the RFB client version. read() can return a short read, whereas stream_read() waits until the full version string is read. Submitted by: Ka Ho Ng Reviewed by: grehan MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D23591 --- usr.sbin/bhyve/rfb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/rfb.c b/usr.sbin/bhyve/rfb.c index 94ea275ba5b7..a53559e18f73 100644 --- a/usr.sbin/bhyve/rfb.c +++ b/usr.sbin/bhyve/rfb.c @@ -76,6 +76,7 @@ static int rfb_debug = 0; #define DPRINTF(params) if (rfb_debug) PRINTLN params #define WPRINTF(params) PRINTLN params +#define VERSION_LENGTH 12 #define AUTH_LENGTH 16 #define PASSWD_LENGTH 8 @@ -769,7 +770,7 @@ rfb_handle(struct rfb_softc *rc, int cfd) stream_write(cfd, vbuf, strlen(vbuf)); /* 1b. Read client version */ - len = read(cfd, buf, sizeof(buf)); + len = stream_read(cfd, buf, VERSION_LENGTH); /* 2a. Send security type */ buf[0] = 1;