From patchwork Wed Jan 23 17:16:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 215008 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BA02C2C0089 for ; Thu, 24 Jan 2013 04:16:32 +1100 (EST) Received: from localhost ([::1]:43569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ty3w3-00005z-Fi for incoming@patchwork.ozlabs.org; Wed, 23 Jan 2013 12:16:27 -0500 Received: from eggs.gnu.org ([208.118.235.92]:54390) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ty3vq-0008Re-Ij for qemu-devel@nongnu.org; Wed, 23 Jan 2013 12:16:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ty3vl-0000si-Rw for qemu-devel@nongnu.org; Wed, 23 Jan 2013 12:16:13 -0500 Received: from oxygen.pond.sub.org ([2a01:4f8:121:10e4::3]:41363) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ty3vl-0000qk-MN; Wed, 23 Jan 2013 12:16:09 -0500 Received: from blackfin.pond.sub.org (p5B32AAD4.dip.t-dialin.net [91.50.170.212]) by oxygen.pond.sub.org (Postfix) with ESMTPA id 9455C9FE47; Wed, 23 Jan 2013 18:16:00 +0100 (CET) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 110FA200AA; Wed, 23 Jan 2013 18:16:00 +0100 (CET) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 23 Jan 2013 18:16:00 +0100 Message-Id: <1358961360-15623-1-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.11.7 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a01:4f8:121:10e4::3 Cc: qemu-trivial@nongnu.org, thardeck@suse.de Subject: [Qemu-devel] [PATCH] vnc: Clean up vncws_send_handshake_response() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Use appropriate types, drop superfluous casts, use sizeof, don't exploit that this particular call of gnutls_fingerprint() doesn't change its last argument. Signed-off-by: Markus Armbruster Reviewed-by: Tim Hardeck --- ui/vnc-ws.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/vnc-ws.c b/ui/vnc-ws.c index 9ccdc19..de7e74c 100644 --- a/ui/vnc-ws.c +++ b/ui/vnc-ws.c @@ -120,8 +120,8 @@ static char *vncws_extract_handshake_entry(const char *handshake, static void vncws_send_handshake_response(VncState *vs, const char* key) { char combined_key[WS_CLIENT_KEY_LEN + WS_GUID_LEN + 1]; - char hash[SHA1_DIGEST_LEN]; - size_t hash_size = SHA1_DIGEST_LEN; + unsigned char hash[SHA1_DIGEST_LEN]; + size_t hash_size = sizeof(hash); char *accept = NULL, *response = NULL; gnutls_datum_t in; @@ -133,7 +133,7 @@ static void vncws_send_handshake_response(VncState *vs, const char* key) in.size = WS_CLIENT_KEY_LEN + WS_GUID_LEN; if (gnutls_fingerprint(GNUTLS_DIG_SHA1, &in, hash, &hash_size) == GNUTLS_E_SUCCESS) { - accept = g_base64_encode((guchar *)hash, SHA1_DIGEST_LEN); + accept = g_base64_encode(hash, hash_size); } if (accept == NULL) { VNC_DEBUG("Hashing Websocket combined key failed\n");