Fix uninitialized digest_len field, causing WebSocket handshake to g_assert.

g_checksum_get_digest checks to ensure that the passed digest_len is long
enough to hold the digest, before setting it to the actual length of the
digest returned.  Digest_len is uninitialized in the code, so if you're
lucky it will be larger than 20 and everything will work fine.  If you're
unlucky, g_checksum_get_digest will return either -1 or some number less
than 20, and the g_assert(digest_len==20) will fail.
This commit is contained in:
C. Scott Ananian 2011-11-11 16:26:12 -05:00 committed by Alexander Larsson
parent e19cbd7a04
commit 981efc90b4

View File

@ -660,8 +660,8 @@ send_error (HttpRequest *request,
static gchar *
generate_handshake_response_wsietf_v7 (const gchar *key)
{
guchar digest[20];
gsize digest_len;
gsize digest_len = 20;
guchar digest[digest_len];
GChecksum *checksum;
checksum = g_checksum_new (G_CHECKSUM_SHA1);