<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17606">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Friendly Automation: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">config.c: Prevent UB in ast_realtime_require_field.<br><br>A backend's implementation of the realtime 'require' function may call<br>va_arg() and then fail, leaving the va_list in an undefined<br>state. Pass a copy of the va_list instead.<br><br>ASTERISK-29771 #close<br><br>Change-Id: I555565a72af84e96d49f62fe8cb66ba5a78461f4<br>---<br>M main/config.c<br>1 file changed, 5 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/config.c b/main/config.c</span><br><span>index 46f05aa..c5e42fa 100644</span><br><span>--- a/main/config.c</span><br><span>+++ b/main/config.c</span><br><span>@@ -3384,16 +3384,19 @@</span><br><span> struct ast_config_engine *eng;</span><br><span> char db[256];</span><br><span> char table[256];</span><br><span style="color: hsl(0, 100%, 40%);">- va_list ap;</span><br><span style="color: hsl(120, 100%, 40%);">+ va_list ap, aq;</span><br><span> int res = -1, i;</span><br><span> </span><br><span> va_start(ap, family);</span><br><span> for (i = 1; ; i++) {</span><br><span> if ((eng = find_engine(family, i, db, sizeof(db), table, sizeof(table)))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ va_copy(aq, ap);</span><br><span> /* If the require succeeds, it returns 0. */</span><br><span style="color: hsl(0, 100%, 40%);">- if (eng->require_func && !(res = eng->require_func(db, table, ap))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ if (eng->require_func && !(res = eng->require_func(db, table, aq))) {</span><br><span style="color: hsl(120, 100%, 40%);">+ va_end(aq);</span><br><span> break;</span><br><span> }</span><br><span style="color: hsl(120, 100%, 40%);">+ va_end(aq);</span><br><span> } else {</span><br><span> break;</span><br><span> }</span><br><span></span><br></pre><div style="white-space:pre-wrap"></div><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17606">change 17606</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/c/asterisk/+/17606"/><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-Change-Id: I555565a72af84e96d49f62fe8cb66ba5a78461f4 </div>
<div style="display:none"> Gerrit-Change-Number: 17606 </div>
<div style="display:none"> Gerrit-PatchSet: 3 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-Reviewer: Benjamin Keith Ford <bford@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>