Module: kamailio
Branch: master
Commit: 72bbf9280879475dcdbda59f00b75a274885abaa
URL:
https://github.com/kamailio/kamailio/commit/72bbf9280879475dcdbda59f00b75a2…
Author: Carsten Bock <carsten(a)ng-voice.com>
Committer: Carsten Bock <carsten(a)ng-voice.com>
Date: 2018-01-18T20:11:50+01:00
CDP: Safety checks and warnings for adding applications to a peer definition
---
Modified: src/modules/cdp/peer.h
Modified: src/modules/cdp/peerstatemachine.c
---
Diff:
https://github.com/kamailio/kamailio/commit/72bbf9280879475dcdbda59f00b75a2…
Patch:
https://github.com/kamailio/kamailio/commit/72bbf9280879475dcdbda59f00b75a2…
---
diff --git a/src/modules/cdp/peer.h b/src/modules/cdp/peer.h
index c4005515fd..daea465519 100644
--- a/src/modules/cdp/peer.h
+++ b/src/modules/cdp/peer.h
@@ -101,6 +101,7 @@ typedef struct _peer_t{
str src_addr; /**< IP Address used to connect to the peer */
app_config *applications;/**< list of supported applications */
+ int applications_max; /**< size of list of supporter applications*/
int applications_cnt; /**< size of list of supporter applications*/
gen_lock_t *lock; /**< lock for operations with this peer */
diff --git a/src/modules/cdp/peerstatemachine.c b/src/modules/cdp/peerstatemachine.c
index 641ec8c7bd..5100e508e8 100644
--- a/src/modules/cdp/peerstatemachine.c
+++ b/src/modules/cdp/peerstatemachine.c
@@ -670,9 +670,15 @@ void add_peer_application(peer *p, int id, int vendor, app_type
type)
p->applications[i].vendor == vendor &&
p->applications[i].type == type) return;
+ if (p->applications_cnt > p->applications_max) {
+ LM_ERR("Too many applications for this peer (max %i), not adding Application
%i:%i.\n", p->applications_max, id, vendor);
+ return;
+ }
+
p->applications[p->applications_cnt].id = id;
p->applications[p->applications_cnt].vendor = vendor;
p->applications[p->applications_cnt].type = type;
+ LM_DBG("Application %i of maximum %i\n", p->applications_cnt,
p->applications_max);
p->applications_cnt++;
}
@@ -724,6 +730,7 @@ void save_peer_applications(peer *p,AAAMessage *msg)
}
p->applications_cnt = 0;
p->applications = shm_malloc(sizeof(app_config)*total_cnt);
+ p->applications_max = total_cnt;
if (!p->applications){
LM_ERR("save_peer_applications(): Error allocating %ld bytes! No applications
saved...\n",
(long int)(sizeof(app_config)*total_cnt));
@@ -1305,5 +1312,3 @@ void Rcv_Process(peer *p, AAAMessage *msg)
// AAAPrintMessage(msg);
}
-
-