From aefb2fa3c3c9be723076d3fd49c5a4f69121f715 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Tue, 19 Dec 2017 17:36:22 -0800 Subject: [PATCH] bad logic for throwCantUnpack("cmdsize") [simple] https://github.com/upx/upx/issues/161 modified: p_mach.cpp --- src/p_mach.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mach.cpp b/src/p_mach.cpp index ce297ca5..f9a3829a 100644 --- a/src/p_mach.cpp +++ b/src/p_mach.cpp @@ -1563,7 +1563,7 @@ void PackMachBase::unpack(OutputFile *fo) memcpy(&msegcmd[j], ptr, umin(sizeof(Mach_segment_command), ((Mach_command const *)ptr)->cmdsize)); ptr += (unsigned) ((Mach_command const *)ptr)->cmdsize; - if (ptr_udiff(ptr, mhdr) > ph.u_len) { + if (ptr_udiff(ptr, (1+ mhdr)) > ph.u_len) { throwCantUnpack("cmdsize"); } }