Browse Source

modules/websocket: removed another magic number

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

+ 3 - 3
modules/websocket/ws_handshake.c

@@ -78,8 +78,7 @@ static str str_status_service_unavailable = str_init("Service Unavailable");
 #define HDR_BUF_LEN		(256)
 #define HDR_BUF_LEN		(256)
 static char headers_buf[HDR_BUF_LEN];
 static char headers_buf[HDR_BUF_LEN];
 
 
-#define KEY_BUF_LEN		(28)
-static char key_buf[KEY_BUF_LEN];
+static char key_buf[base64_enc_len(SHA_DIGEST_LENGTH)];
 
 
 static int ws_send_reply(sip_msg_t *msg, int code, str *reason, str *hdrs)
 static int ws_send_reply(sip_msg_t *msg, int code, str *reason, str *hdrs)
 {
 {
@@ -289,7 +288,8 @@ int ws_handle_handshake(struct sip_msg *msg)
 	pkg_free(reply_key.s);
 	pkg_free(reply_key.s);
 	reply_key.s = key_buf;
 	reply_key.s = key_buf;
 	reply_key.len = base64_enc(sha1, SHA_DIGEST_LENGTH,
 	reply_key.len = base64_enc(sha1, SHA_DIGEST_LENGTH,
-				(unsigned char *) reply_key.s, KEY_BUF_LEN);
+				(unsigned char *) reply_key.s,
+				base64_enc_len(SHA_DIGEST_LENGTH));
 
 
 	/* Add the connection to the WebSocket connection table */
 	/* Add the connection to the WebSocket connection table */
 	wsconn_add(msg->rcv);
 	wsconn_add(msg->rcv);