diff options
author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2015-07-28 15:34:46 +0800 |
---|---|---|
committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2015-08-06 00:32:19 +0800 |
commit | 407985ae9220df2189d529f8d602679e42af6b0b (patch) | |
tree | e4ce1c3dd54f883056aba329adaf51cdb31afbce | |
parent | a83276a8c5f3b39a212c0a22c98b2729647c27c6 (diff) | |
download | libsoup-407985ae9220df2189d529f8d602679e42af6b0b.tar.gz |
soup-websocket.c: #define The Fixed Digest Length
Some compilers (such as Visual Studio) do not like the notion of a[b],
where b is a variable (or even a const int), so #define the (fixed) digest
length for compute_accept_key() to be 20, and use that, so that things will
build and run in such situations.
https://bugzilla.gnome.org/show_bug.cgi?id=752952
-rw-r--r-- | libsoup/soup-websocket.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libsoup/soup-websocket.c b/libsoup/soup-websocket.c index 2c39b1ad..7c19efda 100644 --- a/libsoup/soup-websocket.c +++ b/libsoup/soup-websocket.c @@ -28,6 +28,8 @@ #include "soup-headers.h" #include "soup-message.h" +#define FIXED_DIGEST_LEN 20 + /** * SECTION:soup-websocket * @short_description: The WebSocket Protocol @@ -177,8 +179,8 @@ validate_key (const char *key) static char * compute_accept_key (const char *key) { - gsize digest_len = 20; - guchar digest[digest_len]; + gsize digest_len = FIXED_DIGEST_LEN; + guchar digest[FIXED_DIGEST_LEN]; GChecksum *checksum; if (!key) @@ -195,7 +197,7 @@ compute_accept_key (const char *key) g_checksum_get_digest (checksum, digest, &digest_len); g_checksum_free (checksum); - g_assert (digest_len == 20); + g_assert (digest_len == FIXED_DIGEST_LEN); return g_base64_encode (digest, digest_len); } |