diff --git a/libr/fs/fs.c b/libr/fs/fs.c index 9ae7added4..5247f3b40c 100644 --- a/libr/fs/fs.c +++ b/libr/fs/fs.c @@ -3,7 +3,6 @@ #include #include #include "types.h" -#include #if WITH_GPL # ifndef USE_GRUB @@ -22,7 +21,7 @@ static RFSPlugin* fs_static_plugins[] = { R_FS_STATIC_PLUGINS }; -R_API RFS* r_fs_new(void) { +R_API R_MUSTUSE RFS* r_fs_new(void) { int i; RFSPlugin* static_plugin; RFS* fs = R_NEW0 (RFS); @@ -67,14 +66,13 @@ R_API RFSPlugin* r_fs_plugin_get(RFS* fs, const char* name) { } R_API void r_fs_free(RFS* fs) { - if (!fs) { - return; + if (fs) { + //r_io_free (fs->iob.io); + //root makes use of plugin so revert to avoid UaF + r_list_free (fs->roots); + r_list_free (fs->plugins); + free (fs); } - //r_io_free (fs->iob.io); - //root makes use of plugin so revert to avoid UaF - r_list_free (fs->roots); - r_list_free (fs->plugins); - free (fs); } /* plugins */ @@ -579,13 +577,8 @@ R_API RList* r_fs_partitions(RFS* fs, const char* ptype, ut64 delta) { return list; } if (R_STR_ISNOTEMPTY (ptype)) { - R_LOG_ERROR ("Unknown partition type '%s'", ptype); + R_LOG_ERROR ("Unknown partition type '%s'. Use 'mL' command to list them all", ptype); } - eprintf ("Supported types:\n"); - for (i = 0; partitions[i].name; i++) { - eprintf (" %s", partitions[i].name); - } - eprintf ("\n"); return NULL; } diff --git a/libr/fs/p/fs_grub_base.c b/libr/fs/p/fs_grub_base.c index cc080d8802..65c1d94c65 100644 --- a/libr/fs/p/fs_grub_base.c +++ b/libr/fs/p/fs_grub_base.c @@ -56,7 +56,6 @@ static RList *FSP(_dir)(RFSRoot *root, const char *path, int view) { gfs = root->ptr; list = r_list_new (); -// eprintf ("r_fs_???_dir: %s\n", path); //gfs->file->device->data = &root->iob; grubfs_bind_io (&root->iob, root->delta); gfs->file->fs->dir (gfs->file->device, path, dirhook, 0); diff --git a/libr/fs/p/fs_io.c b/libr/fs/p/fs_io.c index e17565e820..59312cd534 100644 --- a/libr/fs/p/fs_io.c +++ b/libr/fs/p/fs_io.c @@ -57,7 +57,7 @@ static int fs_io_read(RFSFile *file, ut64 addr, int len) { if (res) { int encoded_size = strlen (res); if (encoded_size != len * 2) { - eprintf ("Unexpected size (%d vs %d)\n", encoded_size, len*2); + R_LOG_ERROR ("Unexpected size (%d vs %d)", encoded_size, len * 2); R_FREE (res); return -1; } @@ -68,7 +68,7 @@ static int fs_io_read(RFSFile *file, ut64 addr, int len) { } int ret = r_hex_str2bin (res, file->data); if (ret != len) { - eprintf ("Inconsistent read\n"); + R_LOG_ERROR ("Inconsistent read"); R_FREE (file->data); } R_FREE (res); diff --git a/libr/fs/p/fs_r2.c b/libr/fs/p/fs_r2.c index 9ff062d2f2..84a342fbb9 100644 --- a/libr/fs/p/fs_r2.c +++ b/libr/fs/p/fs_r2.c @@ -120,7 +120,6 @@ static int fs_r2_read(RFSFile *file, ut64 addr, int len) { } static void fs_r2_close(RFSFile *file) { - // eprintf ("TODO: fs.r2.close\n"); //fclose (file->ptr); } diff --git a/libr/fs/p/part_dos.c b/libr/fs/p/part_dos.c index 2c98c2b456..b11fb19f81 100644 --- a/libr/fs/p/part_dos.c +++ b/libr/fs/p/part_dos.c @@ -1,10 +1,8 @@ -/* radare2 - LGPL - Copyright 2015-2017 - pancake */ - -/* XXX: maybe this should be implemented in RBin */ -/* we need to extract the code section and get offset flags */ +/* radare2 - LGPL - Copyright 2015-2022 - pancake */ #include #include + R_PACKED ( typedef struct { ut8 flag; // 0x80 if active @@ -36,11 +34,10 @@ static int fs_part_dos(void *disk, void *ptr, void *closure) { memset (&mbr, 0, sizeof (mbr)); fs->iob.read_at (fs->iob.io, 0, (ut8*)&mbr, sizeof (mbr)); if (mbr.aa55 != 0xaa55) { - eprintf ("Invalid DOS signature at 0x%x\n", - (int)r_offsetof (MBR, aa55)); + R_LOG_ERROR ("Invalid DOS signature at 0x%x", (int)r_offsetof (MBR, aa55)); return 0; } - for (i=0; i<4; i++) { + for (i = 0; i < 4; i++) { ut64 addr, aend; DOS_ENTRY *e = &mbr.entries[i]; if (e->type != 0) { diff --git a/libr/fs/shell.c b/libr/fs/shell.c index 086b315646..991670a882 100644 --- a/libr/fs/shell.c +++ b/libr/fs/shell.c @@ -46,7 +46,7 @@ R_API int r_fs_shell_prompt(RFSShell* shell, RFS* fs, const char* root) { r_str_trim_path (buf); list = r_fs_root (fs, buf); if (r_list_empty (list)) { - printf ("Unknown root\n"); + R_LOG_ERROR ("Unknown root"); r_list_free (list); return false; } @@ -140,8 +140,7 @@ R_API int r_fs_shell_prompt(RFSShell* shell, RFS* fs, const char* root) { ls++; *ls = 0; } - // TODO: adjust contents between // - if (r_str_startswith (me, base)) { + if (r_str_startswith (base, path)) { cb_printf ("m %s\n", (r->path && r->path[0]) ? r->path + 1: ""); } free (base);