The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=04336c0562488080300e68157ada5bc8eae71e54

commit 04336c0562488080300e68157ada5bc8eae71e54
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2022-10-27 14:46:36 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2022-10-27 14:48:55 +0000

    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
---
 usr.sbin/bhyve/rfb.c | 7 +++++--
 1 file 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;

Reply via email to