]> git.feebdaed.xyz Git - 0xmirror/radare2.git/commitdiff
More leaks fixed for r2r. Workaround the system() random fail
authorpancake <pancake@nopcode.org>
Wed, 17 Dec 2025 20:14:17 +0000 (21:14 +0100)
committerpancake <pancake@nowsecure.com>
Wed, 17 Dec 2025 21:28:14 +0000 (22:28 +0100)
binr/r2r/load.c
binr/r2r/r2r.c
binr/r2r/r2r.h
binr/r2r/run.c

index a34034857d009d4ddfd1e137a5788f4e91042eca..56a2523c0da66435af5f7320bc6db9dd82e27213 100644 (file)
@@ -601,7 +601,7 @@ static bool database_load(R2RTestDatabase *db, const char *path, int depth, bool
                        }
                        if (!strcmp (subname, "extras")) {
                                // Only load "extras" dirs if explicitly specified
-                               R_LOG_WARN ("Skipping %s" R_SYS_DIR "%s because it requires additional dependencies", path, subname);
+                               R_LOG_WARN ("Skipping %s" R_SYS_DIR "%s because it requires additional dependencies", shortpath (path), subname);
                                continue;
                        }
 #if WANT_V35 == 0
@@ -609,10 +609,12 @@ static bool database_load(R2RTestDatabase *db, const char *path, int depth, bool
                        size_t i = 0;
                        for (; i < sizeof (v35_tests_to_skip) / sizeof (R2RTestToSkip); i++) {
                                R2RTestToSkip test = v35_tests_to_skip[i];
-                               bool is_dir = r_str_endswith (path, r_str_newf (R_SYS_DIR "%s", test.dir));
+                               char *testdir = r_str_newf (R_SYS_DIR "%s", test.dir);
+                               bool is_dir = r_str_endswith (path, testdir);
+                               free (testdir);
                                if (is_dir) {
                                        if (!strcmp (subname, test.name)) {
-                                               R_LOG_WARN ("Skipping test %s" R_SYS_DIR "%s because it requires arm.v35", path, subname);
+                                               R_LOG_WARN ("Skipping test %s" R_SYS_DIR "%s because it requires arm.v35", shortpath (path), subname);
                                                skip = true;
                                                break;
                                        }
@@ -623,11 +625,11 @@ static bool database_load(R2RTestDatabase *db, const char *path, int depth, bool
                        }
 #endif
                        if (skip_asm && test_from.type == R2R_TEST_TYPE_ASM) {
-                               R_LOG_INFO ("R2R_SKIP_ASM: Skipping %s", path);
+                               R_LOG_INFO ("R2R_SKIP_ASM: Skipping %s", shortpath (path));
                                continue;
                        }
                        if (test_from.archos && (skip_archos || strcmp (subname, archos))) {
-                               R_LOG_INFO ("Skipping %s" R_SYS_DIR "%s because it does not match the current platform \"%s\"", path, subname, archos);
+                               R_LOG_INFO ("Skipping %s" R_SYS_DIR "%s because it does not match the current platform \"%s\"", shortpath (path), subname, archos);
                                continue;
                        }
                        char *subpath = r_file_new (path, subname, NULL);
index bf18d922e1ddc5298fca91c0cd2a56b42edb4005..27f1bd024bd2fd478a4e9398fd3fa0cd06d02d84 100644 (file)
@@ -71,14 +71,6 @@ static void results_clear(RVecR2RTestResultInfoPtr *vec) {
        RVecR2RTestResultInfoPtr_fini (vec);
 }
 
-static const char *shortpath (const char *testpath) {
-       char *shorter = strstr (testpath, "/db/");
-       if (shorter) {
-               return shorter + 1;
-       }
-       return testpath;
-}
-
 static void parse_skip(const char *arg) {
        if (strstr (arg, "arch")) {
                r_sys_setenv ("R2R_SKIP_ARCHOS", "1");
@@ -506,14 +498,17 @@ static bool validate_suite(R2RState *state) {
        R_LOG_INFO ("R2R_RADARE2: %s", state->run_config.r2_cmd);
        R_LOG_INFO ("R2R_RASM2: %s", state->run_config.rasm2_cmd);
        if (r_sys_cmdf ("%s -v", state->run_config.r2_cmd) != 0) {
-               R_LOG_ERROR ("Failed to run r2 -v");
-               return false;
+               if (r_sys_cmdf ("%s -v", state->run_config.r2_cmd) != 0) {
+                       R_LOG_ERROR ("Failed to run r2 -v");
+                       return false;
+               }
        }
        printf ("%s-%d  r2r\n", R2_GITTAP, R2_ABIVERSION);
        // TODO: check if r2r binary version is the same as the r2/rasm2 ones
        if (r_sys_cmdf ("%s -V", state->run_config.r2_cmd) != 0) {
                R_LOG_ERROR ("Inconsistent versions of r2 and its libraries");
-               return false;
+               r_sys_sleep (3);
+               // return false;
        }
        return true;
 }
index 249294b2ed23a20d6f69f8f8d1680f0e5a0508ce..0f346078ca3d5c6b93556edf2cd82264ee59ef69 100644 (file)
@@ -196,6 +196,19 @@ typedef struct r2r_test_result_info_t {
        };
 } R2RTestResultInfo;
 
+static inline const char *shortpath (const char *testpath) {
+       char *shorter = strstr (testpath, "/db/");
+       if (shorter) {
+               return shorter + 1;
+       }
+       shorter = strstr (testpath, "/bins/fuzzed");
+       if (shorter) {
+               return shorter + 6;
+       }
+       return testpath;
+}
+
+
 R_API R2RCmdTest *r2r_cmd_test_new(void);
 R_API void r2r_cmd_test_free(R2RCmdTest *test);
 R_API RVecR2RCmdTestPtr *r2r_load_cmd_test_file(const char *file);
index eb96ca39a2e9b408f80cd2913f90c853014582b4..4e3e1625fb6b761413888add0107c267762f00cb 100644 (file)
@@ -1416,7 +1416,7 @@ R_API char *r2r_test_name(R2RTest *test) {
        case R2R_TEST_TYPE_JSON:
                return r_str_newf ("<json> %s", r_str_get (test->json_test->cmd));
        case R2R_TEST_TYPE_FUZZ:
-               return r_str_newf ("<fuzz> %s", test->path);
+               return r_str_newf ("done"); // <fuzz> %s", shortpath (test->path));
        }
        return NULL;
 }