Commit ddd7011
committed
fix filename_set_extension to always terminate the resulting string with null
Nasm produces heap buffer overload when invoked with the following command line:
$ nasm 1.asm
-fsanitize=address prints the following call stack:
READ of size 1 at 0x5020000000b2 thread T0
#0 0x646bbff40d3d in quote_for_pmake asm/nasm.c:744
#1 0x646bbff3ffa3 in main asm/nasm.c:564
#2 0x76656662a1c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
#3 0x76656662a28a in __libc_start_main_impl ../csu/libc-start.c:360
#4 0x646bbff3be84 in _start (nasm+0x34be84)
The problem is caused by the fact that:
* ofmt::extension for raw binary file is a empty string "",
* when filename_set_extension is called with empty string as extension
it produces a non-null-terminated string,
* the result of filename_set_extension is passed to quote_for_pmake,
which expects a null-terminated string.
This commit fixes the bug by changing filename_set_extension so
it always appends the null terminator to the resulting string.
Signed-off-by: Ivan Sorokin <vanyacpp@gmail.com>1 parent 22a9118 commit ddd7011
1 file changed
+4
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
219 | 219 | | |
220 | 220 | | |
221 | 221 | | |
222 | | - | |
| 222 | + | |
223 | 223 | | |
224 | | - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
0 commit comments