From bce7af4e11f05f1b4c96bee47e07e95946d4867b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20Moln=C3=A1r?= Date: Wed, 28 Aug 2013 22:31:40 +0200 Subject: [PATCH] fixed 8 bit range checking in ElfLinkerAMD64::relocate1 --- src/linker.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/linker.cpp b/src/linker.cpp index 34463a92..d5296a96 100644 --- a/src/linker.cpp +++ b/src/linker.cpp @@ -625,10 +625,12 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location, return super::relocate1(rel, location, value, type); type += 9; + bool range_check = false; if (strncmp(type, "PC", 2) == 0) { value -= rel->section->offset + rel->offset; type += 2; + range_check = true; } if (strcmp(type, "8") == 0) @@ -638,7 +640,7 @@ void ElfLinkerAMD64::relocate1(const Relocation *rel, upx_byte *location, #else int displ = (signed char) *location + (int) value; #endif - if (displ < -128 || displ > 127) + if (range_check && (displ < -128 || displ > 127)) internal_error("target out of range (%d) in reloc %s:%x\n", displ, rel->section->name, rel->offset); *location += value;