Browse code

pv_headers: safety check for xavi key count

* check that we have keys to put into the hash before
allocating anything
* check table field instead of size just to make analyzer happy

Victor Seva authored on 15/04/2021 09:41:20
Showing 1 changed files
... ...
@@ -174,6 +174,10 @@ int pvh_apply_headers(struct sip_msg *msg)
174 174
 		return -1;
175 175
 	}
176 176
 	keys_count = pvh_xavi_keys_count(&sub);
177
+	if(keys_count <= 0) {
178
+		LM_ERR("no keys found: %.*s\n", xavi_name.len, xavi_name.s);
179
+		return -1;
180
+	}
177 181
 	if(str_hash_alloc(&rm_hdrs, keys_count) < 0) {
178 182
 		PKG_MEM_ERROR;
179 183
 		return -1;
... ...
@@ -294,7 +298,7 @@ int pvh_apply_headers(struct sip_msg *msg)
294 298
 	res = 1;
295 299
 
296 300
 err:
297
-	if(rm_hdrs.size)
301
+	if(rm_hdrs.table)
298 302
 		pvh_str_hash_free(&rm_hdrs);
299 303
 	return res;
300 304
 }