Skip to content

Commit

Permalink
Fix the symbol parsing in Plan9 ##bin
Browse files Browse the repository at this point in the history
* Skip symbol type 'Z'
* Use r_buf_read_at instead of r_buf_read8_at since UT8_MAX is a valid value
  • Loading branch information
shurizzle authored Jul 2, 2024
1 parent 762088e commit 31d0fa3
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions libr/bin/p/bin_p9.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,21 @@ static RList *symbols(RBinFile *bf) {
case 'b':
break;
// TODO: source file line offset
case 'Z':
case 'Z': {
ut64 fin = (o->header.syms > offset)? o->header.syms - offset: 0;
for (i = 0; i < fin; i += sizeof (ut16)) {
ut16 index = r_buf_read_be16_at (bf->buf, syms + offset + i);
if (index == UT16_MAX) {
goto error;
}

// read indices until a zero index
if (index == 0) {
offset += i + sizeof (ut16);
break;
}
}
}
// fallthrough
default:
sym_fini (&sym, NULL);
Expand Down Expand Up @@ -531,8 +545,9 @@ static RList *symbols(RBinFile *bf) {

ut64 prev = line;

const ut8 b = r_buf_read8_at (bf->buf, pcs + offset);
if (b == UT8_MAX) {
ut8 b;
st64 r = r_buf_read_at (bf->buf, pcs + offset, &b, sizeof (b));
if (r != sizeof (b)) {
goto error;
}
offset += sizeof (ut8);
Expand Down

0 comments on commit 31d0fa3

Please sign in to comment.