Blob Blame History Raw
From 276b748aa6021c38a2dc699153f61b10e76bc3d2 Mon Sep 17 00:00:00 2001
From: John Reiser <jreiser@BitWagon.com>
Date: Sun, 21 Jul 2019 07:40:21 -0700
Subject: [PATCH] Ignore malformed ElfXX_Shdr in search for .text or .note

https://github.com/upx/upx/issues/287
	modified:   p_vmlinx.cpp
---
 src/p_vmlinx.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/p_vmlinx.cpp b/src/p_vmlinx.cpp
index 65c16c84..3fc26bbe 100644
--- a/src/p_vmlinx.cpp
+++ b/src/p_vmlinx.cpp
@@ -577,6 +577,7 @@ int PackVmlinuxBase<T>::canUnpack()
     Shdr *p;
     for (p= shdri, j= ehdri.e_shnum; --j>=0; ++p) {
         if ((unsigned)file_size < (p->sh_size + p->sh_offset)
+        || (5+ p->sh_name) < p->sh_name  // wrap: ignore malformed
         ||  shstrsec->sh_size < (5+ p->sh_name) ) {
             continue;
         }