<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9887">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_resolver_unbound: Fix leak of config nameserver strings.<br><br>Change-Id: I3f396316bb40d1ae6e91f5f688042420f1a540ed<br>---<br>M res/res_resolver_unbound.c<br>1 file changed, 6 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/87/9887/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_resolver_unbound.c b/res/res_resolver_unbound.c</span><br><span>index 25f6150..89a934c 100644</span><br><span>--- a/res/res_resolver_unbound.c</span><br><span>+++ b/res/res_resolver_unbound.c</span><br><span>@@ -432,20 +432,22 @@</span><br><span> </span><br><span> if (cfg->global->nameservers) {</span><br><span> struct ao2_iterator it_nameservers;</span><br><span style="color: hsl(0, 100%, 40%);">- const char *nameserver;</span><br><span style="color: hsl(120, 100%, 40%);">+ char *nameserver;</span><br><span> </span><br><span> it_nameservers = ao2_iterator_init(cfg->global->nameservers, 0);</span><br><span style="color: hsl(0, 100%, 40%);">- while ((nameserver = ao2_iterator_next(&it_nameservers))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ while (!res && (nameserver = ao2_iterator_next(&it_nameservers))) {</span><br><span> res = ub_ctx_set_fwd(cfg->global->state->resolver->context, (UNBOUND_CHAR *)nameserver);</span><br><span> </span><br><span> if (res) {</span><br><span> ast_log(LOG_ERROR, "Failed to add nameserver '%s' to unbound resolver: %s\n",</span><br><span> nameserver, ub_strerror(res));</span><br><span style="color: hsl(0, 100%, 40%);">- ao2_iterator_destroy(&it_nameservers);</span><br><span style="color: hsl(0, 100%, 40%);">- return -1;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+ ao2_ref(nameserver, -1);</span><br><span> }</span><br><span> ao2_iterator_destroy(&it_nameservers);</span><br><span style="color: hsl(120, 100%, 40%);">+ if (res) {</span><br><span style="color: hsl(120, 100%, 40%);">+ return -1;</span><br><span style="color: hsl(120, 100%, 40%);">+ }</span><br><span> }</span><br><span> </span><br><span> if (!strcmp(cfg->global->resolv, "system")) {</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9887">change 9887</a>. To unsubscribe, or for help writing mail filters, 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/9887"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I3f396316bb40d1ae6e91f5f688042420f1a540ed </div>
<div style="display:none"> Gerrit-Change-Number: 9887 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>