]> git.ipfire.org Git - thirdparty/make.git/commit
[SV 64124] Avoid use-after-free in expand_variable_buf()
authorDmitry Goncharov <dgoncharov@users.sf.net>
Sun, 30 Apr 2023 13:39:04 +0000 (09:39 -0400)
committerPaul Smith <psmith@gnu.org>
Sun, 30 Apr 2023 13:41:02 +0000 (09:41 -0400)
commit06c75a35b93ac6ceacf0474e8b3a23d494fcea07
tree3895563959fcc5e3f10bf58e091aea5b4ac2b3ec
parentebe0a1c9f1d1529a3f2c64d628686f500d460b0e
[SV 64124] Avoid use-after-free in expand_variable_buf()

When the expanded value of the variable in buf occupies more space
than available in variable_buffer, function variable_buffer_output
reallocates variable_buffer: return a pointer into the new memory,
not the old memory.

* src/expand.c (expand_variable_buf): Preserve the offset of buf and
return that offset into the (potentially reallocated) buffer.
* tests/scripts/features/expand: Add tests.
src/expand.c
tests/scripts/features/expand [new file with mode: 0644]