Skip to content

Commit

Permalink
Merge remote-tracking branch 'sdefresne/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
nygard committed Mar 12, 2019
2 parents 58d6825 + 48c261b commit 1f15e74
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Source/CDLCSegment.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ - (id)initWithDataCursor:(CDMachOFileDataCursor *)cursor;
_segmentCommand.cmdsize = [cursor readInt32];

_name = [cursor readStringOfLength:16 encoding:NSASCIIStringEncoding];
memcpy(_segmentCommand.segname, [_name UTF8String], sizeof(_segmentCommand.segname));
size_t nameLength = [_name lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
memcpy(_segmentCommand.segname, [_name UTF8String], MIN(sizeof(_segmentCommand.segname), nameLength));
_segmentCommand.vmaddr = [cursor readPtr];
_segmentCommand.vmsize = [cursor readPtr];
_segmentCommand.fileoff = [cursor readPtr];
Expand Down
6 changes: 4 additions & 2 deletions Source/CDSection.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ - (id)initWithDataCursor:(CDMachOFileDataCursor *)cursor segment:(CDLCSegment *)
_segment = segment;

_sectionName = [cursor readStringOfLength:16 encoding:NSASCIIStringEncoding];
memcpy(_section.sectname, [_sectionName UTF8String], sizeof(_section.sectname));
size_t sectionNameLength = [_sectionName lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
memcpy(_section.sectname, [_sectionName UTF8String], MIN(sectionNameLength, sizeof(_section.sectname)));
size_t segmentNameLength = [_sectionName lengthOfBytesUsingEncoding:NSUTF8StringEncoding];
_segmentName = [cursor readStringOfLength:16 encoding:NSASCIIStringEncoding];
memcpy(_section.segname, [_segmentName UTF8String], sizeof(_section.segname));
memcpy(_section.segname, [_segmentName UTF8String], MIN(segmentNameLength, sizeof(_section.segname)));
_section.addr = [cursor readPtr];
_section.size = [cursor readPtr];
_section.offset = [cursor readInt32];
Expand Down

0 comments on commit 1f15e74

Please sign in to comment.