diff options
author | Mark Johnston <markj@FreeBSD.org> | 2022-10-27 17:46:36 +0300 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2022-10-27 17:48:55 +0300 |
commit | 04336c0562488080300e68157ada5bc8eae71e54 (patch) | |
tree | d27ba0f597c9eaf11b308b9f8e1462a66b3ff05d /usr.sbin | |
parent | e7c13cf4383d8216149becf7f843a2e00b30d2e2 (diff) |
bhyve: Make sure that the VNC version is initialized
clang warned that "client_ver" can be left uninitialized. This change
causes the new connection to be dropped if a version string is not
presented.
MFC after: 1 week
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D37117
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bhyve/rfb.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/bhyve/rfb.c b/usr.sbin/bhyve/rfb.c index 7f7a3514051e..2640a67902e1 100644 --- a/usr.sbin/bhyve/rfb.c +++ b/usr.sbin/bhyve/rfb.c @@ -885,9 +885,12 @@ rfb_handle(struct rfb_softc *rc, int cfd) /* 1b. Read client version */ len = stream_read(cfd, buf, VERSION_LENGTH); - if (len == VERSION_LENGTH && !strncmp(vbuf, buf, VERSION_LENGTH - 2)) { - client_ver = buf[VERSION_LENGTH - 2]; + if (len != VERSION_LENGTH || + strncmp(vbuf, buf, VERSION_LENGTH - 2) != 0) { + goto done; } + + client_ver = buf[VERSION_LENGTH - 2]; if (client_ver != CVERS_3_8 && client_ver != CVERS_3_7) { /* only recognize 3.3, 3.7 & 3.8. Others dflt to 3.3 */ client_ver = CVERS_3_3; |