From patchwork Fri Jan 25 08:56:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: vnc: Clean up vncws_send_handshake_response() Date: Thu, 24 Jan 2013 22:56:50 -0000 From: Tim Hardeck X-Patchwork-Id: 215585 Message-Id: <1359104210.6884.5.camel@Thinktank.site> To: Markus Armbruster Cc: qemu-trivial@nongnu.org, qemu-devel@nongnu.org Hi Markus, thanks for your input. On Wed, 2013-01-23 at 18:16 +0100, Markus Armbruster wrote: > Use appropriate types, drop superfluous casts, use sizeof, don't > exploit that this particular call of gnutls_fingerprint() doesn't > change its last argument. your patch does work fine but if we expect gnutls_fingerprint to change the hash_size there has to be an additional check if the hash_size is bigger than SHA1_DIGEST_LEN. For example: if (accept == NULL) { diff --git a/ui/vnc-ws.c b/ui/vnc-ws.c index de7e74c..e64c895 100644 --- a/ui/vnc-ws.c +++ b/ui/vnc-ws.c @@ -132,7 +132,7 @@ static void vncws_send_handshake_response(VncState *vs, const char* key) in.data = (void *)combined_key; in.size = WS_CLIENT_KEY_LEN + WS_GUID_LEN; if (gnutls_fingerprint(GNUTLS_DIG_SHA1, &in, hash, &hash_size) - == GNUTLS_E_SUCCESS) { + == GNUTLS_E_SUCCESS && hash_size <= SHA1_DIGEST_LEN) { accept = g_base64_encode(hash, hash_size); }