Open yuzhichang opened 1 year ago
Following patch print unexpected klen and vlen and advance s->pos
accordingly:
diff --git a/shlr/sdb/src/sdb.c b/shlr/sdb/src/sdb.c
index f7e744b694..1e2144cdcb 100644
--- a/shlr/sdb/src/sdb.c
+++ b/shlr/sdb/src/sdb.c
@@ -982,6 +982,7 @@ SDB_API bool sdb_dump_dupnext(Sdb* s, char *key, char **value, int *_vlen) {
if (!cdb_getkvlen (&s->db, &klen, &vlen, s->pos)) {
return false;
}
+ uint32_t sign_off = s->pos;
s->pos += 4;
if (klen < 1 || vlen < 1) {
return false;
@@ -996,6 +997,9 @@ SDB_API bool sdb_dump_dupnext(Sdb* s, char *key, char **value, int *_vlen) {
return 0;
}
key[klen] = 0;
+ }else{
+ printf("Got unexpected klen %d at offset %x\n", klen, sign_off);
+ s->pos += klen;
}
}
if (value) {
@@ -1011,6 +1015,9 @@ SDB_API bool sdb_dump_dupnext(Sdb* s, char *key, char **value, int *_vlen) {
return false;
}
(*value)[vlen] = 0;
+ }else{
+ printf("Got unexpected vlen %d at offset %x\n", vlen, sign_off);
+ s->pos += vlen;
}
}
return true;
With the above patch, zo
catches unexpected klen and vlen, and continue loading signatures after that failed one.
[0x0007f2c0]> zo /data01/zhichyu/grpc_whl/notstripped/1.44.0-cygrpc.cpython-310-x86_64-linux-gnu.so.sdb
Got unexpected klen 255 at offset d19c1 ********HERE!********
WARN: Skipping signature with invalid key ()
ERROR: cannot deserialize zign
ERROR: Invalid types: ```void __cxa_throw (void *thrown_exception, struct std::type_info *tinfo, void *dest)``` in signatuer for zign|*|imp.__cxa_throw
ERROR: cannot deserialize zign
The four bytes at offset 0xd19c1 of the sdb file is FF 0E 18 00
:
@radare Looks like radare cannot handle symbols longer than 254 bytes. However mangled long function name is common.
Thanks for the patch. Now we entered into the abi breaking season. Can you submit a pr for that? The size limit will be removed too
Is it appropriate to extend the size limit of symbol from 255 to 65535?
Optimizing zos
from O(n*n) to O(n) would be more important than this issue.
More than defining a larger limit is about to use char* insyead of a fixed size. Its abi breaking season now so its time to do those changes :) the abidiff job is disabled. And yes other optimizations and the need to support mangled name storage will be done too. Agree perf is important here
Ping?
Moving fed because enotime to chk as usual. Would be good if the person who filled the ticket could verify it because i think it should work
@trufae The latest r2
still has the issue.
Environment
Description
zo
failed to load some signatures(unfortunately they are just what I'm interested in).Test
Generate signature file:
Load signature file: