Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fill the memory with zeros on dylib_command allocation #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions macho_edit/load_command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,24 @@ std::string LoadCommand::description() const {

break;
}
#ifdef LC_BUILD_VERSION
case LC_VERSION_MIN_TVOS:
case LC_VERSION_MIN_WATCHOS: {
auto *c = (version_min_command *)raw_lc;
o << ": " << c->version << "-" << c->sdk;
break;
}
case LC_NOTE: {
auto *c = (note_command *)raw_lc;
o << ": " << std::string(c->data_owner, ELEMENTS(c->data_owner));
break;
}
case LC_BUILD_VERSION: {
auto *c = (build_version_command *)raw_lc;
o << ": " << c->platform << "-" << c->minos << "-" << c->sdk << "-" << c->ntools;
break;
}
#endif
}

return o.str();
Expand Down
6 changes: 6 additions & 0 deletions macho_edit/magicnames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ std::string cmd_name(uint32_t cmd) {
RET_NAME(LC_ENCRYPTION_INFO_64);
RET_NAME(LC_LINKER_OPTION);
RET_NAME(LC_LINKER_OPTIMIZATION_HINT);
#ifdef LC_BUILD_VERSION
RET_NAME(LC_VERSION_MIN_TVOS);
RET_NAME(LC_VERSION_MIN_WATCHOS);
RET_NAME(LC_NOTE);
RET_NAME(LC_BUILD_VERSION);
#endif
}

std::ostringstream o;
Expand Down
2 changes: 1 addition & 1 deletion macho_edit/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ load_command *get_path_cmd(const char *prompt, size_t header_size, uint32_t *cmd
uint32_t path_size = (uint32_t)ROUND_UP(path.length() + 1, PATH_PADDING);
*cmdsize = (uint32_t)header_size + path_size;

load_command *lc = (load_command *)malloc(*cmdsize);
load_command *lc = (load_command *)calloc(*cmdsize, sizeof(char));
memcpy(((uint8_t *)lc) + header_size, path.c_str(), path.length());
return lc;
}
Expand Down