From a07dedb804a82bc01c07072861942dd80c6b6d62 Mon Sep 17 00:00:00 2001 From: pancake Date: Fri, 7 May 2021 18:44:49 +0200 Subject: [PATCH] Fix #18667 - division by zero in the macho parser ##bin --- libr/bin/p/bin_mach0.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libr/bin/p/bin_mach0.c b/libr/bin/p/bin_mach0.c index 207828f5f4259..ee0eb29b97d4c 100644 --- a/libr/bin/p/bin_mach0.c +++ b/libr/bin/p/bin_mach0.c @@ -1,4 +1,4 @@ -/* radare - LGPL - Copyright 2009-2019 - pancake */ +/* radare - LGPL - Copyright 2009-2021 - pancake */ #include #include @@ -771,7 +771,10 @@ static void rebase_buffer(struct MACH0_(obj_t) *obj, ut64 off, RIODesc *fd, ut8 if (!obj->chained_starts[i]) { continue; } - ut64 page_size = obj->chained_starts[i]->page_size; + int page_size = obj->chained_starts[i]->page_size; + if (page_size < 1) { + page_size = 4096; + } ut64 start = obj->segs[i].fileoff; ut64 end = start + obj->segs[i].filesize; if (end >= off && start <= eob) {