[sr-dev] git:master: modules/websocket: Replaced magic number

Peter Dunkley peter.dunkley at crocodile-rcs.com
Mon Aug 13 22:55:58 CEST 2012


Module: sip-router
Branch: master
Commit: 8d3eec4f8fbfb2d037e09b80c5d45b5fc400f729
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8d3eec4f8fbfb2d037e09b80c5d45b5fc400f729

Author: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Committer: Peter Dunkley <peter.dunkley at crocodile-rcs.com>
Date:   Mon Aug 13 21:55:37 2012 +0100

modules/websocket: Replaced magic number

---

 modules/websocket/ws_handshake.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/websocket/ws_handshake.c b/modules/websocket/ws_handshake.c
index d8e34f8..8e7b328 100644
--- a/modules/websocket/ws_handshake.c
+++ b/modules/websocket/ws_handshake.c
@@ -110,7 +110,7 @@ static int ws_send_reply(sip_msg_t *msg, int code, str *reason, str *hdrs)
 int ws_handle_handshake(struct sip_msg *msg)
 {
 	str key = {0, 0}, headers = {0, 0}, reply_key = {0, 0};
-	unsigned char sha1[20];
+	unsigned char sha1[SHA_DIGEST_LENGTH];
 	unsigned int hdr_flags = 0;
 	int version;
 	struct hdr_field *hdr = msg->headers;
@@ -288,7 +288,7 @@ int ws_handle_handshake(struct sip_msg *msg)
 	SHA1((const unsigned char *) reply_key.s, reply_key.len, sha1);
 	pkg_free(reply_key.s);
 	reply_key.s = key_buf;
-	reply_key.len = base64_enc(sha1, 20,
+	reply_key.len = base64_enc(sha1, SHA_DIGEST_LENGTH,
 				(unsigned char *) reply_key.s, KEY_BUF_LEN);
 
 	/* Add the connection to the WebSocket connection table */




More information about the sr-dev mailing list