Fix crash in elf parser found in the mtk-su binary with asan

This commit is contained in:
pancake 2020-03-03 15:07:57 +01:00
parent d88a76d2df
commit cffb724bab
1 changed files with 2 additions and 1 deletions

View File

@ -4014,9 +4014,10 @@ char *Elf_(r_bin_elf_compiler)(ELFOBJ *bin) {
free (buf);
return NULL;
}
buf[sz] = 0;
const size_t buflen = strlen (buf);
char *nullbyte = buf + buflen;
if (nullbyte[1] && buflen < sz) {
if (nullbyte[0] && nullbyte[1] && buflen < sz) {
nullbyte[0] = ' ';
}
buf[sz] = 0;