<p>Neels Hofmeyr <strong>uploaded patch set #2</strong> to this change.</p><p><a href="https://gerrit.osmocom.org/9939">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vty: fix use-after-free and memleaks in is_cmd_ambiguous()<br><br>vty_test: add test against ambiguous cmd causing use-after-free and memory<br>leaks. Add this test along with the fix, because the new test triggers the<br>memory use-after-free and leaks, causing build failures.<br><br>Add cmd_deopt_with_ctx() to allow passing a specific talloc ctx.<br><br>is_cmd_ambiguous(): keep all cmd_deopt() allocations until the function exits.<br>Add a comment explaining why. Before this, if a command matched an optional<br>"[arg]" with square brackets, we would keep it in local var 'matched', but we<br>would free the string it points to at the end of that loop iteration; upon<br>encountering another match, we would attempt to strcmp against the freed<br>'matched'. Instead of adding hard-to-read and -verify free/alloc dances to keep<br>the 'matched' accurately freed/non-freed/..., just keep all cmd_deopt() string<br>allocated until done.<br><br>Needless to say that this should have been implemented on a lower level upon<br>inventing optional args, but at least this is fixing a program crash.<br><br>Related: OS#33903390<br>Change-Id: Ia71ba742108b5ff020997bfb612ad5eb30d04fcd<br>---<br>M src/vty/command.c<br>M tests/vty/vty_test.c<br>M tests/vty/vty_test.ok<br>3 files changed, 124 insertions(+), 20 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/39/9939/2</pre><p>To view, visit <a href="https://gerrit.osmocom.org/9939">change 9939</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.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.osmocom.org/9939"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: libosmocore </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newpatchset </div>
<div style="display:none"> Gerrit-Change-Id: Ia71ba742108b5ff020997bfb612ad5eb30d04fcd </div>
<div style="display:none"> Gerrit-Change-Number: 9939 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Neels Hofmeyr <nhofmeyr@sysmocom.de> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins Builder </div>
<div style="display:none"> Gerrit-CC: Pau Espin Pedrol <pespin@sysmocom.de> </div>
<div style="display:none"> Gerrit-CC: Vadim Yanitskiy <axilirator@gmail.com> </div>