Browse code

topos_redis: check the branch value to avoid using uninitialized fields

- GH #1784

Daniel-Constantin Mierla authored on 08/01/2019 11:24:27
Showing 1 changed files
... ...
@@ -737,8 +737,13 @@ int tps_redis_load_branch(sip_msg_t *msg, tps_data_t *md, tps_data_t *sd,
737 737
 			LM_ERR("failed to load the INVITE branch value\n");
738 738
 			return -1;
739 739
 		}
740
+		memset(&id, 0, sizeof(tps_data_t));
740 741
 		xvbranch1 = &id.x_vbranch1;
741 742
 	}
743
+	if(xvbranch1->len<=0 || xvbranch1->s==NULL) {
744
+		LM_DBG("branch value not found (mode: %u)\n", mode);
745
+		return 1;
746
+	}
742 747
 	rp = _tps_redis_cbuf;
743 748
 	memcpy(rp, _tps_redis_bprefix.s, _tps_redis_bprefix.len);
744 749
 	memcpy(rp + _tps_redis_bprefix.len,