<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/3201/">https://reviewboard.asterisk.org/r/3201/</a>
</td>
</tr>
</table>
<br />
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="8" style="background-image: url('https://reviewboard.asterisk.org/static/rb/images/review_request_box_top_bg.ab6f3b1072c9.png'); background-position: left top; background-repeat: repeat-x; border: 1px black solid;">
<tr>
<td>
<div>Review request for Asterisk Developers and Julian Lyndon-Smith.</div>
<div>By wdoekes.</div>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
Asterisk
</div>
<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;">jmls got the following odd query on his raspberry PI:
[Feb 7 08:36:59] ERROR[3516][C-00000029]: res_config_pgsql.c:167 _pgsql_exec:
PostgreSQL RealTime: Query Failed:
UPDATE h42_voicemail SET context='f5f985...', mailbox='502'
WHERE context='f5f985...' AND mailbox='502'
Notice how that is essentially a no-op.
The cause turned out to be this asterisk 12 code in main/config.c:
va_start(ap);
lookup_fields = realtime_arguments_to_fields(ap);
update_fields = realtime_arguments_to_fields(ap);
va_end(ap);
According to the va_arg manpage, the behaviour of 'ap' after function return is undefined.
In the raspberry case, it was reset, so jmls would get the "lookup fields" twice and never
the "update fields" (the password).
This patch:
- Surrounds both realtime_argument_to_fields calls with a matching va_start+va_end (legal,
according to man).
- Adds a skip parameter to realtime_arguments_to_fields2(ap, skip), so we can skip past the
first arguments on the second call.
- Adds a bunch of early returns for cases when ast_variable_new fails (out of mem?) so the
realtime implementations won't have to crash.</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;">It compiles.
jmls confirmed that the second call using 'ap' yielded the first result set, instead of the expected second.
Waiting on jmls to confirm that this patch fixes his problem.</pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>/branches/12/main/config.c <span style="color: grey">(406079)</span></li>
</ul>
<p><a href="https://reviewboard.asterisk.org/r/3201/diff/" style="margin-left: 3em;">View Diff</a></p>
</td>
</tr>
</table>
</div>
</body>
</html>