[sr-dev] git:4.2: websocket: safety guard when computing the list of connections

Daniel-Constantin Mierla miconda at gmail.com
Thu Oct 16 01:08:42 CEST 2014


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu Oct 16 00:57:29 2014 +0200

websocket: safety guard when computing the list of connections

- avoid going further if connection is null -- unlikely to happen as len
  of the list is computed before

(cherry picked from commit 19e8a5618f86833995d17200267910e44471141d)

---

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

diff --git a/modules/websocket/ws_conn.c b/modules/websocket/ws_conn.c
index 88fe5e8..06f7b13 100644
--- a/modules/websocket/ws_conn.c
+++ b/modules/websocket/ws_conn.c
@@ -486,6 +486,7 @@ ws_connection_t **wsconn_get_list(void)
 	{
 		if (!wsc) {
 			LM_ERR("Wrong list length\n");
+			break;
 		}
 
 		list[i] = wsc;
@@ -494,7 +495,7 @@ ws_connection_t **wsconn_get_list(void)
 
 		wsc = wsc->used_next;
 	}
-	list[list_len] = NULL; /* explicit NULL termination */
+	list[i] = NULL; /* explicit NULL termination */
 
 end:
 	WSCONN_UNLOCK;




More information about the sr-dev mailing list