From owner-svn-src-head@freebsd.org Thu Jun 15 06:21:03 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 35F17C31222; Thu, 15 Jun 2017 06:21:03 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0614265D3A; Thu, 15 Jun 2017 06:21:02 +0000 (UTC) (envelope-from araujo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5F6L2fC008704; Thu, 15 Jun 2017 06:21:02 GMT (envelope-from araujo@FreeBSD.org) Received: (from araujo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5F6L2nF008703; Thu, 15 Jun 2017 06:21:02 GMT (envelope-from araujo@FreeBSD.org) Message-Id: <201706150621.v5F6L2nF008703@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: araujo set sender to araujo@FreeBSD.org using -f From: Marcelo Araujo Date: Thu, 15 Jun 2017 06:21:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319968 - head/usr.sbin/bhyve X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Jun 2017 06:21:03 -0000 Author: araujo Date: Thu Jun 15 06:21:01 2017 New Revision: 319968 URL: https://svnweb.freebsd.org/changeset/base/319968 Log: Initialize variables and use byteorder(9) instead of aliasing char array buf via uint32_t pointer. CID: 1375949 Reported by: Coverity, cem Reviewed by: cem MFC after: 3 weeks Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D11153 Modified: head/usr.sbin/bhyve/rfb.c Modified: head/usr.sbin/bhyve/rfb.c ============================================================================== --- head/usr.sbin/bhyve/rfb.c Thu Jun 15 04:49:12 2017 (r319967) +++ head/usr.sbin/bhyve/rfb.c Thu Jun 15 06:21:01 2017 (r319968) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #ifndef WITHOUT_CAPSICUM #include #endif +#include #include #include #include @@ -754,7 +755,7 @@ rfb_handle(struct rfb_softc *rc, int cfd) { const char *vbuf = "RFB 003.008\n"; unsigned char buf[80]; - unsigned char *message; + unsigned char *message = NULL; #ifndef NO_OPENSSL unsigned char challenge[AUTH_LENGTH]; @@ -766,7 +767,7 @@ rfb_handle(struct rfb_softc *rc, int cfd) #endif pthread_t tid; - uint32_t sres; + uint32_t sres = 0; int len; rc->cfd = cfd; @@ -858,7 +859,7 @@ rfb_handle(struct rfb_softc *rc, int cfd) stream_write(cfd, &sres, 4); if (sres) { - *((uint32_t *) buf) = htonl(strlen(message)); + be32enc(buf, strlen(message)); stream_write(cfd, buf, 4); stream_write(cfd, message, strlen(message)); goto done;