<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="8" style="border: 1px #c9c399 solid;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://reviewboard.asterisk.org/r/2071/">https://reviewboard.asterisk.org/r/2071/</a>
</td>
</tr>
</table>
<br />
<div>
<table width="100%" border="0" bgcolor="white" style="border: 1px solid #C0C0C0; border-collapse: collapse; margin: 2px padding: 2px;">
<thead>
<tr>
<th colspan="4" bgcolor="#F0F0F0" style="border-bottom: 1px solid #C0C0C0; font-size: 9pt; padding: 4px 8px; text-align: left;">
<a href="https://reviewboard.asterisk.org/r/2071/diff/2/?file=30999#file30999line956" style="color: black; font-weight: bold; text-decoration: underline;">/branches/1.8/funcs/func_odbc.c</a>
<span style="font-weight: normal;">
(Diff revision 2)
</span>
</th>
</tr>
</thead>
<tbody style="background-color: #e4d9cb; padding: 4px 8px; text-align: center;">
<tr>
<td colspan="4"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_query **query)</pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">956</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="k">if</span> <span class="p">(</span><span class="n">asprintf</span><span class="p">((</span><span class="kt">char</span> <span class="o">**</span><span class="p">)</span><span class="o">&</span><span class="p">((</span><span class="o">*</span><span class="n">query</span><span class="p">)</span><span class="o">-></span><span class="n">acf</span><span class="o">-></span><span class="n">name</span><span class="p">),</span> <span class="s">"%s_%s"</span><span class="p">,</span> <span class="n">tmp</span><span class="p">,</span> <span class="n">catg</span><span class="p">)</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">956</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="k">if</span> <span class="p">(</span><span class="n"><span class="hl">ast_</span>asprintf</span><span class="p">((</span><span class="kt">char</span> <span class="o">**</span><span class="p">)</span><span class="o">&</span><span class="p">((</span><span class="o">*</span><span class="n">query</span><span class="p">)</span><span class="o">-></span><span class="n">acf</span><span class="o">-></span><span class="n">name</span><span class="p">),</span> <span class="s">"%s_%s"</span><span class="p">,</span> <span class="n">tmp</span><span class="p">,</span> <span class="n">catg</span><span class="p">)</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></td>
</tr>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">957</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                        <span class="n">ast_log</span><span class="p">(</span><span class="n">LOG_WARNING</span><span class="p">,</span> <span class="s">"asprintf() failed: %s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">strerror</span><span class="p">(</span><span class="n">errno</span><span class="p">));</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">957</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                        <span class="o">*</span><span class="n">query</span><span class="o">-></span><span class="n">acf</span><span class="o">-></span><span class="n">name</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span></pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">958</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="p">}</span></pre></td>
<th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">958</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="p">}</span></pre></td>
</tr>
<tr>
<th bgcolor="#f0f0f0" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">959</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></td>
<th bgcolor="#f0f0f0" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">959</font></th>
<td bgcolor="#ffffff" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">        <span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></td>
</tr>
</tbody>
<tbody>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">960</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="k">if</span> <span class="p">(</span><span class="n">asprintf</span><span class="p">((</span><span class="kt">char</span> <span class="o">**</span><span class="p">)</span><span class="o">&</span><span class="p">((</span><span class="o">*</span><span class="n">query</span><span class="p">)</span><span class="o">-></span><span class="n">acf</span><span class="o">-></span><span class="n">name</span><span class="p">),</span> <span class="s">"ODBC_%s"</span><span class="p">,</span> <span class="n">catg</span><span class="p">)</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">960</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                <span class="k">if</span> <span class="p">(</span><span class="n"><span class="hl">ast_</span>asprintf</span><span class="p">((</span><span class="kt">char</span> <span class="o">**</span><span class="p">)</span><span class="o">&</span><span class="p">((</span><span class="o">*</span><span class="n">query</span><span class="p">)</span><span class="o">-></span><span class="n">acf</span><span class="o">-></span><span class="n">name</span><span class="p">),</span> <span class="s">"ODBC_%s"</span><span class="p">,</span> <span class="n">catg</span><span class="p">)</span> <span class="o"><</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span></pre></td>
</tr>
<tr>
<th bgcolor="#e9eaa8" style="border-right: 1px solid #C0C0C0;" align="right"><font size="2">961</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                        <span class="n">ast_log</span><span class="p">(</span><span class="n">LOG_WARNING</span><span class="p">,</span> <span class="s">"asprintf() failed: %s</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="n">strerror</span><span class="p">(</span><span class="n">errno</span><span class="p">));</span></pre></td>
<th bgcolor="#e9eaa8" style="border-left: 1px solid #C0C0C0; border-right: 1px solid #C0C0C0;" align="right"><font size="2">961</font></th>
<td bgcolor="#fdfebc" width="50%"><pre style="font-size: 8pt; line-height: 140%; margin: 0; ">                        <span class="o">*</span><span class="n">query</span><span class="o">-></span><span class="n">acf</span><span class="o">-></span><span class="n">name</span> <span class="o">=</span> <span class="nb">NULL</span><span class="p">;</span></pre></td>
</tr>
</tbody>
</table>
<pre style="margin-left: 2em; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Compiler error:
*query->acf->name = NULL;
Should be:
(*query)->acf->name = NULL;</pre>
</div>
<br />
<p>- rmudgett</p>
<br />
<p>On August 16th, 2012, 6:21 p.m., Mark Michelson wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/media/rb/images/review_request_box_top_bg.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers and rmudgett.</div>
<div>By Mark Michelson.</div>
<p style="color: grey;"><i>Updated Aug. 16, 2012, 6:21 p.m.</i></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">This contains several fixes involving the misuse of asprintf()
* All uses of asprintf() have been changed to ast_asprintf() and all uses of vasprintf() have been changed to ast_vasprintf(). This is because these are typically paired with calls to ast_free(). When using MALLOC_DEBUG, we must pair ast_ allocation calls with ast_free() or else unfun things happen.
* All uses of ast_asprintf() are now checked for failure. The biggest offender here was xmldoc.c. If there are errors in this review, this is the most likely file to find them.
* Any failure cases of ast_asprintf() that result in the allocated memory being potentially referenced later now explicitly NULLs out the pointer because asprintf() does not define what the pointer will be pointing to after an allocation failure.
* Fixed a memory leak in res_config_sqlite3 where an ast_asprintf() call did not have the resultant allocated memory freed.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;">Compiled, ran Asterisk, and ran some calls. Nothing catastrophic occurred.</pre>
</td>
</tr>
</table>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Bugs: </b>
<a href="https://issues.asterisk.org/jira/browse/ASTERISK-20135">ASTERISK-20135</a>
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/1.8/main/file.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/main/utils.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/main/xmldoc.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/pbx/pbx_config.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/res/res_config_sqlite.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/res/res_jabber.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/channels/chan_sip.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/funcs/func_odbc.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/apps/app_dial.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/apps/app_queue.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/apps/app_stack.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/cdr/cdr_tds.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/channels/chan_dahdi.c <span style="color: grey">(371391)</span></li>
<li>/branches/1.8/channels/chan_oss.c <span style="color: grey">(371391)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/2071/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>