소스 검색

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
Daniel-Constantin Mierla 11 년 전
부모
커밋
19e8a5618f
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      modules/websocket/ws_conn.c

+ 2 - 1
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;