[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sr-dev
Subject:    [sr-dev] git:master:0dbf0863: htable: safety check for item name value
From:       Daniel-Constantin Mierla <miconda () gmail ! com>
Date:       2020-01-29 9:46:06
Message-ID: E1iwjvC-0005Wj-Og () www ! kamailio ! org
[Download RAW message or body]

Module: kamailio
Branch: master
Commit: 0dbf08635a4b2f6e544c26da0a7f542f1863939b
URL: https://github.com/kamailio/kamailio/commit/0dbf08635a4b2f6e544c26da0a7f542f1863939b

Author: Daniel-Constantin Mierla <miconda@gmail.com>
Committer: Daniel-Constantin Mierla <miconda@gmail.com>
Date: 2020-01-29T10:45:28+01:00

htable: safety check for item name value

---

Modified: src/modules/htable/ht_api.c

---

Diff:  https://github.com/kamailio/kamailio/commit/0dbf08635a4b2f6e544c26da0a7f542f1863939b.diff
Patch: https://github.com/kamailio/kamailio/commit/0dbf08635a4b2f6e544c26da0a7f542f1863939b.patch

---

diff --git a/src/modules/htable/ht_api.c b/src/modules/htable/ht_api.c
index 4812e8aacd..7bade571c3 100644
--- a/src/modules/htable/ht_api.c
+++ b/src/modules/htable/ht_api.c
@@ -237,6 +237,10 @@ ht_t* ht_get_table(str *name)
 	unsigned int htid;
 	ht_t *ht;
 
+	if(name==NULL || name->s==NULL) {
+		LM_WARN("invalid name parameter\n");
+		return NULL;
+	}
 	htid = ht_compute_hash(name);
 
 	/* does it exist */
@@ -263,6 +267,10 @@ int ht_add_table(str *name, int autoexp, str *dbtable, str *dbcols, int size,
 	int c;
 	int i;
 
+	if(name==NULL || name->s==NULL) {
+		LM_WARN("invalid name parameter\n");
+		return -1;
+	}
 	htid = ht_compute_hash(name);
 
 	/* does it exist */
@@ -463,8 +471,14 @@ int ht_set_cell_ex(ht_t *ht, str *name, int type, int_str *val, int mode,
 	ht_cell_t *it, *prev, *cell;
 	time_t now;
 
-	if(ht==NULL || ht->entries==NULL)
+	if(ht==NULL || ht->entries==NULL) {
+		LM_WARN("invalid ht parameter\n");
 		return -1;
+	}
+	if(name==NULL || name->s==NULL) {
+		LM_WARN("invalid name parameter\n");
+		return -1;
+	}
 
 	hid = ht_compute_hash(name);
 
@@ -639,6 +653,10 @@ int ht_del_cell(ht_t *ht, str *name)
 	if(ht==NULL || ht->entries==NULL)
 		return -1;
 
+	if(name==NULL || name->s==NULL) {
+		LM_WARN("invalid name parameter\n");
+		return -1;
+	}
 	hid = ht_compute_hash(name);
 
 	idx = ht_get_entry(hid, ht->htsize);
@@ -685,6 +703,10 @@ ht_cell_t* ht_cell_value_add(ht_t *ht, str *name, int val, ht_cell_t *old)
 	if(ht==NULL || ht->entries==NULL)
 		return NULL;
 
+	if(name==NULL || name->s==NULL) {
+		LM_WARN("invalid name parameter\n");
+		return NULL;
+	}
 	hid = ht_compute_hash(name);
 
 	idx = ht_get_entry(hid, ht->htsize);
@@ -807,6 +829,10 @@ ht_cell_t* ht_cell_pkg_copy(ht_t *ht, str *name, ht_cell_t *old)
 	if(ht==NULL || ht->entries==NULL)
 		return NULL;
 
+	if(name==NULL || name->s==NULL) {
+		LM_WARN("invalid name parameter\n");
+		return NULL;
+	}
 	hid = ht_compute_hash(name);
 
 	idx = ht_get_entry(hid, ht->htsize);
@@ -860,6 +886,10 @@ int ht_cell_exists(ht_t *ht, str *name)
 	if(ht==NULL || ht->entries==NULL)
 		return 0;
 
+	if(name==NULL || name->s==NULL) {
+		LM_WARN("invalid name parameter\n");
+		return -1;
+	}
 	hid = ht_compute_hash(name);
 
 	idx = ht_get_entry(hid, ht->htsize);
@@ -1197,6 +1227,10 @@ int ht_set_cell_expire(ht_t *ht, str *name, int type, int_str *val)
 	if(ht->htexpire==0)
 		return 0;
 
+	if(name==NULL || name->s==NULL) {
+		LM_WARN("invalid name parameter\n");
+		return -1;
+	}
 	hid = ht_compute_hash(name);
 
 	idx = ht_get_entry(hid, ht->htsize);
@@ -1242,6 +1276,10 @@ int ht_get_cell_expire(ht_t *ht, str *name, unsigned int *val)
 	if(ht->htexpire==0)
 		return 0;
 
+	if(name==NULL || name->s==NULL) {
+		LM_WARN("invalid name parameter\n");
+		return -1;
+	}
 	hid = ht_compute_hash(name);
 
 	idx = ht_get_entry(hid, ht->htsize);


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic