[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [PATCH] vnc: Clean up vncws_send_handshake_response()
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-trivial] [PATCH] vnc: Clean up vncws_send_handshake_response() |
Date: |
Fri, 25 Jan 2013 10:23:06 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) |
Tim Hardeck <address@hidden> writes:
> 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:
>
> 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);
> }
> if (accept == NULL) {
Makes sense. I'll respin. Thanks!