From 0e6cef99a009d6864b5fef6d7931f83c49fe5d12 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Wed, 1 May 2024 10:09:52 -0700 Subject: [PATCH] Guard against empty PT_NOTE https://github.com/upx/upx/issues/817 modified: p_lx_elf.cpp --- src/p_lx_elf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_lx_elf.cpp b/src/p_lx_elf.cpp index 71ce6dbc..9855805c 100644 --- a/src/p_lx_elf.cpp +++ b/src/p_lx_elf.cpp @@ -3984,8 +3984,8 @@ void PackLinuxElf32::pack1(OutputFile * /*fo*/, Filter &ft) phdr = phdri; for (unsigned j=0; j < e_phnum; ++phdr, ++j) { unsigned const type = get_te32(&phdr->p_type); - if (PT_NOTE32 == type) { - unsigned const len = get_te32(&phdr->p_filesz); + unsigned const len = get_te32(&phdr->p_filesz); + if (PT_NOTE32 == type && len && note_body.getSize()) { fi->seek(get_te32(&phdr->p_offset), SEEK_SET); fi->readx(¬e_body[note_size], len); note_size += up4(len);