<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/7738">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">cdr: Missing NULL check and unlock.<br><br>* handle_dial_message: Missing a check for NULL peer.<br>* cdr_generic_register: Missing unlock on allocation failure.<br><br>cdr_generic_register is fixed by reordering so the new structure is<br>allocated and initialized before locking the list.<br><br>Change-Id: I5799b99270d1a7a716a555c31ac85f4b00ce8686<br>---<br>M main/cdr.c<br>1 file changed, 26 insertions(+), 12 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/38/7738/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/main/cdr.c b/main/cdr.c<br>index 0f6a665..bb56844 100644<br>--- a/main/cdr.c<br>+++ b/main/cdr.c<br>@@ -2097,7 +2097,12 @@<br> if (!peer && !caller) {<br> return;<br> }<br>- if (filter_channel_snapshot(peer) || (caller && filter_channel_snapshot(caller))) {<br>+<br>+ if (peer && filter_channel_snapshot(peer)) {<br>+ return;<br>+ }<br>+<br>+ if (caller && filter_channel_snapshot(caller)) {<br> return;<br> }<br> <br>@@ -2871,32 +2876,41 @@<br> <br> static int cdr_generic_register(struct be_list *generic_list, const char *name, const char *desc, ast_cdrbe be)<br> {<br>- struct cdr_beitem *i = NULL;<br>+ struct cdr_beitem *i;<br>+ struct cdr_beitem *cur;<br> <br>- if (!name)<br>+ if (!name) {<br> return -1;<br>+ }<br> <br> if (!be) {<br> ast_log(LOG_WARNING, "CDR engine '%s' lacks backend\n", name);<br>+<br> return -1;<br> }<br> <br>- AST_RWLIST_WRLOCK(generic_list);<br>- AST_RWLIST_TRAVERSE(generic_list, i, list) {<br>- if (!strcasecmp(name, i->name)) {<br>- ast_log(LOG_WARNING, "Already have a CDR backend called '%s'\n", name);<br>- AST_RWLIST_UNLOCK(generic_list);<br>- return -1;<br>- }<br>- }<br>+ i = ast_calloc(1, sizeof(*i))<br>+ if (!i) {<br>+ ast_log(LOG_WARNING, "Failed to allocate space for CDR engine '%s'\n", name);<br> <br>- if (!(i = ast_calloc(1, sizeof(*i))))<br> return -1;<br>+ }<br> <br> i->be = be;<br> ast_copy_string(i->name, name, sizeof(i->name));<br> ast_copy_string(i->desc, desc, sizeof(i->desc));<br> <br>+ AST_RWLIST_WRLOCK(generic_list);<br>+ AST_RWLIST_TRAVERSE(generic_list, cur, list) {<br>+ if (!strcasecmp(name, cur->name)) {<br>+ ast_log(LOG_WARNING, "Already have a CDR backend called '%s'\n", name);<br>+ AST_RWLIST_UNLOCK(generic_list);<br>+ ast_free(i);<br>+<br>+ return -1;<br>+ }<br>+ }<br>+<br> AST_RWLIST_INSERT_HEAD(generic_list, i, list);<br> AST_RWLIST_UNLOCK(generic_list);<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/7738">change 7738</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/7738"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I5799b99270d1a7a716a555c31ac85f4b00ce8686 </div>
<div style="display:none"> Gerrit-Change-Number: 7738 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>