@@ -127,7 +127,7 @@ static void r_binfmt_macho64_load_mlist(r_binfmt_s *bin) {
127
127
128
128
/* Check the fields of the machoXX segment */
129
129
static int r_binfmt_macho64_check_segment (r_binfmt_s * bin , r_binfmt_macho64_segment_s * seg ) {
130
- u32 filesz , fileoff ;
130
+ u64 filesz , fileoff ;
131
131
u64 off ;
132
132
133
133
off = ((byte_t * )seg ) - bin -> mapped ;
@@ -154,7 +154,7 @@ static int r_binfmt_macho64_check_segment(r_binfmt_s *bin, r_binfmt_macho64_segm
154
154
static int r_binfmt_macho64_check (r_binfmt_s * bin ) {
155
155
r_binfmt_macho64_header_s * hdr ;
156
156
r_binfmt_macho_cmd_s * cmd ;
157
- u32 tmp , i , cmd_num , off , type ;
157
+ u32 tmp , i , cmd_num , cmd_size , off , type ;
158
158
159
159
/* Already checked in r_binfmt_machoXX_is(),
160
160
but if the check is removed in the future, the
@@ -181,12 +181,15 @@ static int r_binfmt_macho64_check(r_binfmt_s *bin) {
181
181
182
182
/* Now check command */
183
183
type = r_binfmt_get_int32 ((byte_t * )& cmd -> type , bin -> endian );
184
- if (type == R_BINFMT_MACHO_CMD_TYPE_SEGMENT ) {
184
+ if (type == R_BINFMT_MACHO_CMD_TYPE_SEGMENT64 ) {
185
185
if (!r_binfmt_macho64_check_segment (bin , (r_binfmt_macho64_segment_s * )cmd ))
186
186
return 0 ;
187
187
}
188
188
189
- if (!r_utils_add32 (& off , off , r_binfmt_get_int32 ((byte_t * )& cmd -> size , bin -> endian )))
189
+ cmd_size = r_binfmt_get_int32 ((byte_t * )& cmd -> size , bin -> endian );
190
+ if (!cmd_size )
191
+ return 0 ;
192
+ if (!r_utils_add32 (& off , off , cmd_size ))
190
193
return 0 ;
191
194
}
192
195
0 commit comments