Skip to content

Commit

Permalink
Clear PE format 'has_canary' function
Browse files Browse the repository at this point in the history
  • Loading branch information
Roeegg2 committed Nov 13, 2024
1 parent 2012869 commit f3cc97e
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions librz/bin/p/bin_pe.inc
Original file line number Diff line number Diff line change
Expand Up @@ -639,28 +639,17 @@ err:

static int has_canary(RzBinFile *bf) {
// TODO: use O(1) when imports sdbized
struct PE_(rz_bin_pe_obj_t) *bin = bf->o->bin_obj;
void **it;
if (bin) {
// const RzPVector *relocs_vec = bin->relocs;
// RzBinReloc *rel;
// if (relocs_vec) {
// rz_pvector_foreach (relocs_vec, it) {
// rel = *it;
// if (!strcmp(rel->import->name, "__security_init_cookie")) {
// return true;
// }
// }
// }
} else { // rz_bin needs this as it will not initialise bin
const RzPVector *imports_vec = imports(bf);
RzBinImport *imp;
if (imports_vec) {
rz_pvector_foreach (imports_vec, it) {
imp = *it;
if (!strcmp(imp->name, "__security_init_cookie")) {
return true;
}
const RzPVector *imports_vec = imports(bf);
RzBinImport *imp;
if (imports_vec) {
rz_pvector_foreach (imports_vec, it) {
imp = *it;
// __security_init_cookie is a function imported from msvcrt.dll (libc) that when called
// initiliazes the stack canary. So if the function is imported, we can
// assume the binary uses stack canary.
if (!strcmp(imp->name, "__security_init_cookie")) {
return true;
}
}
}
Expand Down

0 comments on commit f3cc97e

Please sign in to comment.