Browse code

core: xavp - safety checks for name len

(cherry picked from commit d22d812da1c3b2a2f65f142ef5ed5fa07e8ab072)

Daniel-Constantin Mierla authored on 13/05/2021 15:41:40
Showing 1 changed files
... ...
@@ -106,7 +106,7 @@ static sr_xavp_t *xavp_new_value(str *name, sr_xval_t *val)
106 106
 	int size;
107 107
 	unsigned int id;
108 108
 
109
-	if(name==NULL || name->s==NULL || val==NULL)
109
+	if(name==NULL || name->s==NULL || name->len<=0 || val==NULL)
110 110
 		return NULL;
111 111
 	id = get_hash1_raw(name->s, name->len);
112 112
 
... ...
@@ -427,7 +427,7 @@ static int xavp_rm_internal(str *name, sr_xavp_t **head, int idx)
427 427
 	int n=0;
428 428
 	int count=0;
429 429
 
430
-	if(name==NULL || name->s==NULL)
430
+	if(name==NULL || name->s==NULL || name->len<=0)
431 431
 		return 0;
432 432
 
433 433
 	id = get_hash1_raw(name->s, name->len);
... ...
@@ -498,7 +498,7 @@ int xavp_count(str *name, sr_xavp_t **start)
498 498
 	unsigned int id;
499 499
 	int n = 0;
500 500
 
501
-	if(name==NULL || name->s==NULL)
501
+	if(name==NULL || name->s==NULL || name->len<=0)
502 502
 		return -1;
503 503
 	id = get_hash1_raw(name->s, name->len);
504 504
 
... ...
@@ -865,7 +865,7 @@ sr_xavp_t *xavp_extract(str *name, sr_xavp_t **list)
865 865
 	sr_xavp_t *prv = 0;
866 866
 	unsigned int id;
867 867
 
868
-	if(name==NULL || name->s==NULL) {
868
+	if(name==NULL || name->s==NULL || name->len<=0) {
869 869
 		if(list!=NULL) {
870 870
 			avp = *list;
871 871
 			if(avp!=NULL) {
... ...
@@ -1157,7 +1157,7 @@ static sr_xavp_t *xavu_get_internal(str *name, sr_xavp_t **list, sr_xavp_t **prv
1157 1157
 	sr_xavp_t *avu;
1158 1158
 	unsigned int id;
1159 1159
 
1160
-	if(name==NULL || name->s==NULL) {
1160
+	if(name==NULL || name->s==NULL || name->len<=0) {
1161 1161
 		return NULL;
1162 1162
 	}
1163 1163
 
... ...
@@ -1235,7 +1235,7 @@ int xavu_rm_by_name(str *name, sr_xavp_t **head)
1235 1235
 	unsigned int id;
1236 1236
 
1237 1237
 
1238
-	if(name==NULL || name->s==NULL) {
1238
+	if(name==NULL || name->s==NULL || name->len<=0) {
1239 1239
 		return -1;
1240 1240
 	}
1241 1241
 
... ...
@@ -1579,7 +1579,7 @@ static sr_xavp_t *xavi_new_value(str *name, sr_xval_t *val)
1579 1579
 	int size;
1580 1580
 	unsigned int id;
1581 1581
 
1582
-	if(name==NULL || name->s==NULL || val==NULL)
1582
+	if(name==NULL || name->s==NULL || name->len<=0 || val==NULL)
1583 1583
 		return NULL;
1584 1584
 	id = get_hash1_case_raw(name->s, name->len);
1585 1585
 
... ...
@@ -1812,7 +1812,7 @@ static sr_xavp_t *xavi_get_internal(str *name, sr_xavp_t **list, int idx, sr_xav
1812 1812
 	unsigned int id;
1813 1813
 	int n = 0;
1814 1814
 
1815
-	if(name==NULL || name->s==NULL)
1815
+	if(name==NULL || name->s==NULL || name->len<=0)
1816 1816
 		return NULL;
1817 1817
 	id = get_hash1_case_raw(name->s, name->len);
1818 1818
 
... ...
@@ -1939,7 +1939,7 @@ static int xavi_rm_internal(str *name, sr_xavp_t **head, int idx)
1939 1939
 	int n=0;
1940 1940
 	int count=0;
1941 1941
 
1942
-	if(name==NULL || name->s==NULL)
1942
+	if(name==NULL || name->s==NULL || name->len<=0)
1943 1943
 		return 0;
1944 1944
 
1945 1945
 	id = get_hash1_case_raw(name->s, name->len);
... ...
@@ -2022,7 +2022,7 @@ int xavi_count(str *name, sr_xavp_t **start)
2022 2022
 	unsigned int id;
2023 2023
 	int n = 0;
2024 2024
 
2025
-	if(name==NULL || name->s==NULL)
2025
+	if(name==NULL || name->s==NULL || name->len<=0)
2026 2026
 		return -1;
2027 2027
 	id = get_hash1_case_raw(name->s, name->len);
2028 2028
 
... ...
@@ -2315,7 +2315,7 @@ sr_xavp_t *xavi_extract(str *name, sr_xavp_t **list)
2315 2315
 	sr_xavp_t *prv = 0;
2316 2316
 	unsigned int id;
2317 2317
 
2318
-	if(name==NULL || name->s==NULL) {
2318
+	if(name==NULL || name->s==NULL || name->len<=0) {
2319 2319
 		if(list!=NULL) {
2320 2320
 			avi = *list;
2321 2321
 			if(avi!=NULL) {