diff --git a/src/stub/src/amd64-linux.elf-main.c b/src/stub/src/amd64-linux.elf-main.c index 397aeb41..226b9930 100644 --- a/src/stub/src/amd64-linux.elf-main.c +++ b/src/stub/src/amd64-linux.elf-main.c @@ -350,6 +350,11 @@ auxv_up(Elf64_auxv_t *av, unsigned const type, uint64_t const value) av->a_un.a_val = value; return; } + if (av->a_type==AT_NULL) { + // We can't do this as part of the for loop because we overwrite + // AT_NULL too. + return; + } } } diff --git a/src/stub/src/i386-bsd.elf-main.c b/src/stub/src/i386-bsd.elf-main.c index 62940102..8e2f1226 100644 --- a/src/stub/src/i386-bsd.elf-main.c +++ b/src/stub/src/i386-bsd.elf-main.c @@ -352,6 +352,11 @@ auxv_up(Elf32_auxv_t *av, unsigned const type, unsigned const value) av->a_un.a_val = value; return; } + if (av->a_type==AT_NULL) { + // We can't do this as part of the for loop because we overwrite + // AT_NULL too. + return; + } } } diff --git a/src/stub/src/i386-linux.elf.interp-main.c b/src/stub/src/i386-linux.elf.interp-main.c index c1ee7a8d..7281d35b 100644 --- a/src/stub/src/i386-linux.elf.interp-main.c +++ b/src/stub/src/i386-linux.elf.interp-main.c @@ -223,6 +223,11 @@ auxv_up(Elf32_auxv_t *av, unsigned const type, unsigned const value) av->a_un.a_val = value; return; } + if (av->a_type==AT_NULL) { + // We can't do this as part of the for loop because we overwrite + // AT_NULL too. + return; + } } } diff --git a/src/stub/src/i386-openbsd.elf-main.c b/src/stub/src/i386-openbsd.elf-main.c index e8da8109..3ddcce36 100644 --- a/src/stub/src/i386-openbsd.elf-main.c +++ b/src/stub/src/i386-openbsd.elf-main.c @@ -346,6 +346,11 @@ auxv_up(Elf32_auxv_t *av, unsigned const type, unsigned const value) av->a_un.a_val = value; return; } + if (av->a_type==AT_NULL) { + // We can't do this as part of the for loop because we overwrite + // AT_NULL too. + return; + } } }