<p>Sean Bright has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/17604">View Change</a></p><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;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/04/17604/1</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><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/17604">change 17604</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/+/17604"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I555565a72af84e96d49f62fe8cb66ba5a78461f4 </div>
<div style="display:none"> Gerrit-Change-Number: 17604 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean@seanbright.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>