Skip to content

Commit 02a1f43

Browse files
radaretrufae
authored andcommitted
Check for abiversion before loading plugins ##crash
1 parent 2447562 commit 02a1f43

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

libr/anal/p/anal_null.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ RAnalPlugin r_anal_plugin_null = {
2323
R_API RLibStruct radare_plugin = {
2424
.type = R_LIB_TYPE_ANAL,
2525
.data = &r_anal_plugin_null,
26-
.version = R2_VERSION
26+
.version = R2_VERSION,
27+
.abiversion = R2_ABIVERSION
2728
};
2829
#endif

libr/util/lib.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,14 @@ R_API bool r_lib_validate_plugin(RLib *lib, const char *file, RLibStruct *stru)
403403
return false;
404404
}
405405

406-
// Check version compatibility
407-
if (stru->version && !lib->ignore_version) {
406+
// Check ABI compatibility
407+
if (stru->abiversion && !lib->ignore_abiversion) {
408+
if (stru->abiversion != lib->abiversion) {
409+
R_LOG_WARN ("ABI version mismatch: (ABI %d) vs radare2 (ABI %d) for '%s'", stru->abiversion, lib->abiversion, file);
410+
return false;
411+
}
412+
} else if (stru->version && !lib->ignore_version) {
413+
// Check version compatibility
408414
char *mm0 = major_minor (stru->version);
409415
char *mm1 = major_minor (R2_VERSION);
410416
bool mismatch = strcmp (mm0, mm1);
@@ -425,14 +431,6 @@ R_API bool r_lib_validate_plugin(RLib *lib, const char *file, RLibStruct *stru)
425431
}
426432
}
427433

428-
// Check ABI compatibility
429-
if (stru->abiversion && !lib->ignore_abiversion) {
430-
if (stru->abiversion != lib->abiversion) {
431-
R_LOG_WARN ("ABI version mismatch: (ABI %d) vs radare2 (ABI %d) for '%s'", stru->abiversion, lib->abiversion, file);
432-
return false;
433-
}
434-
}
435-
436434
return true;
437435
}
438436

0 commit comments

Comments
 (0)