Browse Source

modules/websocket: Replaced magic number

Peter Dunkley 13 years ago
parent
commit
8d3eec4f8f
1 changed files with 2 additions and 2 deletions
  1. 2 2
      modules/websocket/ws_handshake.c

+ 2 - 2
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 */