Sfoglia il codice sorgente

jsonrpcs: safety check to see if xhttp transport was initialized

- reported by GH #1030
Daniel-Constantin Mierla 8 anni fa
parent
commit
7ae5210a7b
1 ha cambiato i file con 7 aggiunte e 1 eliminazioni
  1. 7 1
      src/modules/jsonrpcs/jsonrpcs_mod.c

+ 7 - 1
src/modules/jsonrpcs/jsonrpcs_mod.c

@@ -1050,11 +1050,12 @@ error:
 
 static int mod_init(void)
 {
+	memset(&xhttp_api, 0, sizeof(xhttp_api_t));
 
 	/* bind the XHTTP API */
 	if(jsonrpc_transport==0 || (jsonrpc_transport&1)) {
 		if (xhttp_load_api(&xhttp_api) < 0) {
-			if(jsonrpc_transport==1) {
+			if(jsonrpc_transport&1) {
 				LM_ERR("cannot bind to XHTTP API\n");
 				return -1;
 			} else {
@@ -1169,6 +1170,11 @@ static int jsonrpc_dispatch(sip_msg_t* msg, char* s1, char* s2)
 		return NONSIP_MSG_PASS;
 	}
 
+	if(xhttp_api.reply==NULL) {
+		LM_ERR("jsonrpc over http not initialized - check transport param\n");
+		return NONSIP_MSG_ERROR;
+	}
+
 	/* initialize jsonrpc context */
 	ctx = &_jsonrpc_ctx;
 	memset(ctx, 0, sizeof(jsonrpc_ctx_t));