Content-Security-Policy: default-src 'none'
Content-Type: text/plain; charset=UTF-8
Content-Length: 1276
Content-Disposition: inline; filename="atf-execute-with-shell.patch"
Last-Modified: Wed, 12 Feb 2025 09:22:15 GMT
Expires: Sat, 10 Feb 2035 09:22:15 GMT
ETag: "bde4fb336a936b99898ea79266c4b7d03c5df239"

Submitted here: https://github.com/freebsd/atf/pull/57

From 098b66269b1cf1d944b8b214ceb7ce9febde3682 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Date: Mon, 29 Jan 2024 22:35:49 -0500
Subject: [PATCH] Fix use after free in execute_with_shell.

The temporary string returned by atf::env::get would be used outside
its statement, which is invalid and cause undefined behavior.  Copy it
to a local variable to avoid the issue.

Fixes: https://github.com/freebsd/atf/issues/26
Fixes: https://github.com/freebsd/kyua/issues/223

Reported-by: Ruslan Bukin <br@bsdpad.com>
---
 atf-sh/atf-check.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/atf-sh/atf-check.cpp b/atf-sh/atf-check.cpp
index 41f0b13..9d6f7a8 100644
--- a/atf-sh/atf-check.cpp
+++ b/atf-sh/atf-check.cpp
@@ -436,7 +436,9 @@ execute_with_shell(char* const* argv)
     const std::string cmd = flatten_argv(argv);
 
     const char* sh_argv[4];
-    sh_argv[0] = atf::env::get("ATF_SHELL", ATF_SHELL).c_str();
+    co</td></tr></table>
<table class='tabs'><tr><td>
<a href='/guix/about/'>about</a><a href='/guix/'>summary</a><a href='/guix/refs/?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>refs</a><a href='/guix/log/gnu/packages/patches/gpsbabel-fix-i686-test.patch'>log</a><a href='/guix/tree/gnu/packages/patches/gpsbabel-fix-i686-test.patch?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>tree</a><a href='/guix/commit/gnu/packages/patches/gpsbabel-fix-i686-test.patch?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>commit</a><a class='active' href='/guix/diff/gnu/packages/patches/gpsbabel-fix-i686-test.patch?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>diff</a></td><td class='form'><form class='right' method='get' action='/guix/log/gnu/packages/patches/gpsbabel-fix-i686-test.patch'>
<input type='hidden' name='id' value='ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/guix/diff/?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>root</a>/<a href='/guix/diff/gnu?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>gnu</a>/<a href='/guix/diff/gnu/packages?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>packages</a>/<a href='/guix/diff/gnu/packages/patches?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>patches</a>/<a href='/guix/diff/gnu/packages/patches/gpsbabel-fix-i686-test.patch?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>gpsbabel-fix-i686-test.patch</a></div><div class='content'><div class='cgit-panel'><b>diff options</b><form method='get'><input type='hidden' name='id' value='ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><div class='diffstat-header'><a href='/guix/diff/?id=ac8fb4b9f4db0cf774799b95fc176c8a80ade6cc'>Diffstat</a> (limited to 'gnu/packages/patches/gpsbabel-fix-i686-test.patch')</div><table summary='diffstat' class='diffstat'></table><div class='diffstat-summary'>0 files changed, 0 insertions, 0 deletions</div><table summary='diff' class='diff'><tr><td></td></tr></table></div> <!-- class=content -->
                         <div class=footer>generated by
                             <a href="https://git.zx2c4.com/cgit/about/">
                                 cgit
                             </a>
                         </div>
                        </div> <!-- id=cgit -->
</body>
</html>
