Skip to content

Commit

Permalink
fix: bof
Browse files Browse the repository at this point in the history
  • Loading branch information
Soulghost committed Nov 26, 2021
1 parent 0550bc9 commit ff14351
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions iblessing/iblessing-core/core/memory/VirtualMemoryV2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ int VirtualMemoryV2::mappingMachOToEngine(shared_ptr<SymbolTable> symtab, shared
if (seg64->nsects > 0) {
struct ib_section_64 *sect = (struct ib_section_64 *)((uint8_t *)seg64 + sizeof(struct ib_segment_command_64));
for (uint32_t i = 0; i < seg64->nsects; i++) {
char *sectname = (char *)malloc(16);
char *sectname = (char *)malloc(17);
memset(sectname, 0, 17);
memcpy(sectname, sect->sectname, 16);
addr2segInfo[sect->addr] = {string(sect->segname), string(sectname)};
free(sectname);
Expand Down Expand Up @@ -330,7 +331,8 @@ CFString* VirtualMemoryV2::readAsCFString(uint64_t address, bool needCheck) {
}

int checkLen = std::min((int)str->length, 10);
char *tmpBuf = (char *)malloc(checkLen);
char *tmpBuf = (char *)malloc(checkLen + 1);
memset(tmpBuf, 0, checkLen + 1);
err = uc_mem_read(uc, str->data, tmpBuf, checkLen);
if (err != UC_ERR_OK) {
free(str);
Expand Down

0 comments on commit ff14351

Please sign in to comment.