Skip to content

Commit

Permalink
pt/addrtrace: Handle nullptr in dofree
Browse files Browse the repository at this point in the history
  • Loading branch information
aewag committed Mar 2, 2023
1 parent d54e088 commit b288991
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
6 changes: 5 additions & 1 deletion analysis/datastub/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ def search_in_directory(filename, filepath):
# Download source package
command = f"apt-get source {package}"
debug(4, f"exec: {command}")
subprocess.check_output(shlex.split(command))
try:
subprocess.check_output(shlex.split(command))
except subprocess.CalledProcessError:
debug(0, f"Download sources failed for {package}")
return None, 0

DOWNLOADED_PACKAGE_SOURCES.append(bin_file_path)

Expand Down
7 changes: 6 additions & 1 deletion cryptolib/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
test_results
# Ignore everything
/*

# Except for DATA general directories
!common/
!selftest-*/
4 changes: 2 additions & 2 deletions cryptolib/selftest-heap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

set -e

# OPTIONS="--phase1 --phase2 --export --parallel"
OPTIONS="--phase1"
OPTIONS="--phase1 --phase2 --export --parallel"
# OPTIONS="--phase1"
export RESULTDIR=${PWD}/results

cd selftest-heap
Expand Down
16 changes: 8 additions & 8 deletions cryptolib/selftest-heap/dmt-realloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int change(uint16_t number, void** obj);
int readaddr(void** addr, uint16_t number);
int test(uint16_t number, uint8_t key);
#ifdef DEBUG
void printstats(uint16_t number, void** obj);
void printstats(uint16_t number, vector<vector<int>> obj);
void printaddr(uint16_t number, void** addr);
#endif

Expand Down Expand Up @@ -386,12 +386,12 @@ int readaddr(void** addr, uint16_t number)
* @param number number of objects
* @param obj array containing objects
*/
void printstats(uint16_t number, void** obj)
void printstats(uint16_t number, vector<vector<int>> obj)
{
/* total memory */
struct mallinfo mi = mallinfo();
printf("*******************************\n");
printf("Allocated bytes: %d\n", mi.arena);
// struct mallinfo mi = mallinfo();
// printf("*******************************\n");
// printf("Allocated bytes: %d\n", mi.arena);

/* objects entries */
int i;
Expand All @@ -416,9 +416,9 @@ void printaddr(uint16_t number, void** addr)
printf("*******************************\n");
printf("Addresses:\n");
int i;
for (i = 0; i < number; i++) {
printf(" %0*"PRIxPTR"\n", (int)(sizeof(void*) * 2), (uintptr_t)addr[i]);
}
// for (i = 0; i < number; i++) {
// printf(" %0*" PRIxPTR "\n", (int)(sizeof(void*) * 2), (uintptr_t)addr[i]);
// }
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion cryptolib/selftest-heap/framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function cb_pre_run {
#
# $1 ... key file name
function cb_run_command {
echo "${BINARY} 0 0 0 16 $1"
echo "${BINARY} 1 0 1 16 $1"
}

# DATA callback for custom commands that are executed immediately after
Expand Down
3 changes: 2 additions & 1 deletion pintool/addrtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,8 @@ void dofree(ADDRINT addr) {
PT_DEBUG(1, "dofree 0x" << std::hex << addr);

if (!addr) {
PT_ERROR("dofree called with NULL");
PT_DEBUG(3, "dofree called with NULL");
return;
}

if (allocmap.find(addr) == allocmap.end()) {
Expand Down

0 comments on commit b288991

Please sign in to comment.