diff --git a/src/modules/cdp/peer.h b/src/modules/cdp/peer.h index c4005515fd6..daea4655194 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 641ec8c7bdf..5100e508e8a 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); } - -