From 3a6c574376bda64b42cfc76836665b3a93b3b0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Moln=C3=A1r?= Date: Sun, 24 Dec 2006 16:25:36 +0100 Subject: [PATCH] pe: correctly handle import table with 0 entries during decompression (#1620733) --- src/p_armpe.cpp | 3 ++- src/p_w32pe.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/p_armpe.cpp b/src/p_armpe.cpp index 7fbcfa11..d0603c39 100644 --- a/src/p_armpe.cpp +++ b/src/p_armpe.cpp @@ -1027,7 +1027,8 @@ int PackArmPe::canUnpack() void PackArmPe::rebuildImports(upx_byte *& extrainfo) { - if (ODADDR(PEDIR_IMPORT) == 0) + if (ODADDR(PEDIR_IMPORT) == 0 + || ODSIZE(PEDIR_IMPORT) <= sizeof(import_desc)) return; // const upx_byte * const idata = obuf + get_le32(extrainfo); diff --git a/src/p_w32pe.cpp b/src/p_w32pe.cpp index 045e6bf8..3468d24f 100644 --- a/src/p_w32pe.cpp +++ b/src/p_w32pe.cpp @@ -1155,7 +1155,8 @@ int PackW32Pe::canUnpack() void PackW32Pe::rebuildImports(upx_byte *& extrainfo) { - if (ODADDR(PEDIR_IMPORT) == 0) + if (ODADDR(PEDIR_IMPORT) == 0 + || ODSIZE(PEDIR_IMPORT) <= sizeof(import_desc)) return; // const upx_byte * const idata = obuf + get_le32(extrainfo);