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

Print MD5 checksum when available in DWARF5 #23683

Merged
merged 1 commit into from
Nov 25, 2024
Merged
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
23 changes: 19 additions & 4 deletions libr/bin/dwarf.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,7 @@ static const ut8 *parse_line_header_source_dwarf5(RBin *bin, const ut8 *buf, con
if (mode == R_MODE_PRINT) {
print ("\n");
print (" The File Name Table:\n");
print (" Entry Dir Time Size Name\n");
print (" Entry Dir Time Size MD5 Name\n");
}

entry_formatv5 file_form = {0};
Expand Down Expand Up @@ -1040,9 +1040,24 @@ static const ut8 *parse_line_header_source_dwarf5(RBin *bin, const ut8 *buf, con
}
}
if (mode == R_MODE_PRINT) {
// TODO: print md5 checksum if available
print (" %" PFMT64u " %" PFMT32d " %" PFMT32d " %" PFMT32d " %s\n",
i + 1, file->id_idx, file->mod_time, file->file_len, file->name);
// number of hexes chars in a md5 checksum plus NULL
char sumstr[33];

memset (sumstr, ' ', sizeof (sumstr));
sumstr[32] = '\0';

if (file->has_checksum) {
int i;
ut8 *p = &file->md5sum[0];
static const char *hex = "0123456789abcdef";

for (i = 0; i < 16; i++) {
sumstr[i * 2] = hex[(p[i] >> 4) & 0x0f];
sumstr[i * 2 + 1] = hex[p[i] & 0x0f];
}
}
print (" %" PFMT64u " %" PFMT32d " %" PFMT32d " %" PFMT32d " %s %s\n",
i + 1, file->id_idx, file->mod_time, file->file_len, sumstr, file->name);
}
}

Expand Down
Loading
Loading