mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-26 00:55:59 +00:00
Improve sigdb file format detection ##anal
This commit is contained in:
parent
4e9a6e05c4
commit
e18876dd85
@ -2990,38 +2990,27 @@ static int signdb_type(const char *file) {
|
||||
sz = R_MIN (sz, 0x200);
|
||||
int is_sdb = 16;
|
||||
int is_kv = 4;
|
||||
int is_r2 = 4;
|
||||
int is_r2 = 2;
|
||||
int t = SIGNDB_TYPE_INVALID;
|
||||
if (r_str_startswith (data, "[{\"name\":")) {
|
||||
t = SIGNDB_TYPE_JSON;
|
||||
} else {
|
||||
for (i = 0; i < sz; i++) {
|
||||
if (!strncmp (data + i, "\nza ", sz - i)) {
|
||||
if (!strncmp (data + i, "\nza ", 4)) {
|
||||
is_r2--;
|
||||
i++;
|
||||
i += 3;
|
||||
continue;
|
||||
}
|
||||
switch (i) {
|
||||
case 3:
|
||||
case 7:
|
||||
case 0xb:
|
||||
case 0xf:
|
||||
if (data[i] == 0) {
|
||||
is_sdb--;
|
||||
}
|
||||
break;
|
||||
case '=':
|
||||
case '\n':
|
||||
if ((i & 3) == 3 && data[i] == 0) {
|
||||
is_sdb--;
|
||||
continue;
|
||||
}
|
||||
if (data[i] == '=' || data[i] == '\n') {
|
||||
is_kv--;
|
||||
break;
|
||||
default:
|
||||
if (data[i] != 0) {
|
||||
is_sdb--;
|
||||
}
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (is_sdb == 0) {
|
||||
if (is_sdb < 0) {
|
||||
t = SIGNDB_TYPE_SDB;
|
||||
} else if (is_r2 < 0) {
|
||||
t = SIGNDB_TYPE_R2;
|
||||
|
@ -1767,3 +1767,53 @@ za main N sym.imp.atoi
|
||||
za sym.foo_int_ N sym.foo_int__int_
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=Saves and loads sdb zignatures without sdb extension
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
rm .tmp_file
|
||||
za s1 x xref1
|
||||
za s2 r ref1
|
||||
za s3 n sym1
|
||||
za s4 n sym2
|
||||
zos .tmp_file
|
||||
z-*
|
||||
zo .tmp_file
|
||||
z~s1
|
||||
z~s2
|
||||
z~s3
|
||||
z~s4
|
||||
rm .tmp_file
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
s1:
|
||||
s2:
|
||||
s3:
|
||||
s4:
|
||||
EOF
|
||||
RUN
|
||||
|
||||
NAME=Saves and loads r2 zignatures without r2 extension
|
||||
FILE=-
|
||||
CMDS=<<EOF
|
||||
rm .tmp_file
|
||||
za s1 x xref1
|
||||
za s2 r ref1
|
||||
za s3 n sym1
|
||||
za s4 n sym2
|
||||
z* > .tmp_file
|
||||
z-*
|
||||
zo .tmp_file
|
||||
z~s1
|
||||
z~s2
|
||||
z~s3
|
||||
z~s4
|
||||
rm .tmp_file
|
||||
EOF
|
||||
EXPECT=<<EOF
|
||||
s1:
|
||||
s2:
|
||||
s3:
|
||||
s4:
|
||||
EOF
|
||||
RUN
|
||||
|
Loading…
x
Reference in New Issue
Block a user