static int lang_lib_file_run (RLang *user, const char *file) { char *libpath; void *lib; if (!(libpath = r_str_new (file))) { return -1; } if (!r_str_startswith (libpath, "/") && !r_str_startswith (libpath, "./")) { libpath = r_str_prefix (libpath, "./"); } if (!r_file_exists (libpath)) { if (!r_str_endswith (libpath, R_LIB_EXT)) { libpath = r_str_appendf (libpath, ".%s", R_LIB_EXT); } } if (!r_file_exists (libpath)) { free (libpath); return -1; } lib = r_lib_dl_open (libpath); if (lib) { void (*fcn)(RCore *); fcn = r_lib_dl_sym (lib, "entry"); if (fcn) { fcn (user->user); } else { eprintf ("Cannot find 'entry' symbol in library\n"); } r_lib_dl_close (lib); } free (libpath); return 0; }
R_API int r_core_visual_hud(RCore *core) { const char *c = r_config_get (core->config, "hud.path"); const char *f = R2_LIBDIR"/radare2/"R2_VERSION"/hud/main"; char *homehud = r_str_home (R2_HOMEDIR"/hud"); char *res = NULL; char *p = 0; showcursor (core, true); if (c && *c && r_file_exists (c)) res = r_cons_hud_file (c); if (!res && homehud) res = r_cons_hud_file (homehud); if (!res && r_file_exists (f)) res = r_cons_hud_file (f); if (!res) r_cons_message ("Cannot find hud file"); r_cons_clear (); if (res) { p = strchr (res, '\t'); r_cons_printf ("%s\n", res); r_cons_flush (); if (p) r_core_cmd0 (core, p+1); free (res); } showcursor (core, false); r_cons_flush (); free (homehud); return (int)(size_t)p; }
R_API int r_core_project_delete(RCore *core, const char *prjfile) { if (r_sandbox_enable (0)) { eprintf ("Cannot delete project in sandbox mode\n"); return 0; } char *path = projectScriptPath (core, prjfile); if (!path) { eprintf ("Invalid project name '%s'\n", prjfile); return false; } if (r_core_is_project (core, prjfile)) { char *prjDir = r_file_dirname (path); if (!prjDir) { eprintf ("Cannot resolve directory\n"); free (path); return false; } // rm project file if (r_file_exists (path)) { r_file_rm (path); eprintf ("rm %s\n", path); } //rm notes.txt file char *notes_txt = r_str_newf ("%s%s%s", prjDir, R_SYS_DIR, "notes.txt"); if (r_file_exists (notes_txt)) { r_file_rm (notes_txt); eprintf ("rm %s\n", notes_txt); } free(notes_txt); char *rop_d = r_str_newf ("%s%s%s", prjDir, R_SYS_DIR, "rop.d"); if (r_file_is_directory (rop_d)) { char *f; RListIter *iter; RList *files = r_sys_dir (rop_d); r_list_foreach (files, iter, f) { char *filepath = r_str_append (strdup (rop_d), R_SYS_DIR); filepath = r_str_append (filepath, f); if (!r_file_is_directory (filepath)) { eprintf ("rm %s\n", filepath); r_file_rm (filepath); } free (filepath); } r_file_rm (rop_d); eprintf ("rm %s\n", rop_d); r_list_free (files); } free (rop_d); // remove directory only if it's empty r_file_rm (prjDir); free (prjDir); }
static char *projectScriptPath(RCore *core, const char *file) { const char *magic = "# r2 rdb project file"; char *data, *prjfile; if (r_file_is_abspath (file)) { prjfile = strdup (file); } else { if (!is_valid_project_name (file)) { return NULL; } prjfile = r_file_abspath (r_config_get (core->config, "dir.projects")); prjfile = r_str_append (prjfile, R_SYS_DIR); prjfile = r_str_append (prjfile, file); if (!r_file_exists (prjfile) || r_file_is_directory (prjfile)) { prjfile = r_str_append (prjfile, R_SYS_DIR "rc"); } } data = r_file_slurp (prjfile, NULL); if (data) { if (strncmp (data, magic, strlen (magic))) { R_FREE (prjfile); } } free (data); return prjfile; }
static int r_core_visual_hud(RCore *core) { const char *f = R2_LIBDIR"/radare2/"R2_VERSION"/hud/main"; char *homehud = r_str_home (R2_HOMEDIR"/hud"); char *res = NULL; char *p = 0; showcursor (core, R_TRUE); if (homehud) res = r_cons_hud_file (homehud); if (!res) { if (r_file_exists (f)) res = r_cons_hud_file (f); else r_cons_message ("Cannot find hud file"); } r_cons_clear (); if (res) { p = strchr (res, '\t'); core->printidx = 1; r_cons_printf ("%s\n", res); r_cons_flush (); if (p) r_core_cmd0 (core, p+1); free (res); } showcursor (core, R_FALSE); r_cons_flush (); free (homehud); return (int)(size_t)p; }
static bool run_commands(RList *cmds, RList *files, bool quiet) { RListIter *iter; const char *cmdn; const char *file; int ret; /* -i */ r_list_foreach (files, iter, file) { if (!r_file_exists (file)) { eprintf ("Script '%s' not found.\n", file); return false; } ret = r_core_run_script (&r, file); if (ret == -2) { eprintf ("Cannot open '%s'\n", file); } if (ret < 0 || (ret == 0 && quiet)) { r_cons_flush (); return false; } } /* -c */ r_list_foreach (cmds, iter, cmdn) { r_core_cmd0 (&r, cmdn); r_cons_flush (); }
static int print_meta_offset(RCore *core, ut64 offset) { int ret, line, line_old, i; char file[1024]; ret = r_bin_addr2line (core->bin, offset, file, sizeof (file)-1, &line); if (ret) { r_cons_printf ("file %s\nline %d\n", file, line); line_old = line; if (line >= 2) line -= 2; if (r_file_exists (file)) { for (i = 0; i<5; i++) { char *row = r_file_slurp_line (file, line+i, 0); if (row) { r_cons_printf ("%c %.3x %s\n", line+i == line_old ? '>' : ' ', line+i, row); free (row); } } } else { eprintf ("Cannot open '%s'\n", file); } } else { eprintf ("Cannot find meta information at 0x%08" PFMT64x"\n", offset); } return 0; }
static int rabin_delegate(RThread *th) { if (rabin_cmd && r_file_exists (r.file->desc->name)) { char *nptr, *ptr, *cmd = r_sys_cmd_str (rabin_cmd, NULL, NULL); ptr = cmd; if (ptr) { do { if (th) { r_th_lock_enter (th->user); } nptr = strchr (ptr, '\n'); if (nptr) { *nptr = 0; } r_core_cmd (&r, ptr, 0); if (nptr) { ptr = nptr + 1; } if (th) { r_th_lock_leave (th->user); } } while (nptr); } //r_core_cmd (&r, cmd, 0); r_str_free (rabin_cmd); rabin_cmd = NULL; } if (th) eprintf ("rabin2: done\n"); return 0; }
static RThreadFunctionRet rabin_delegate(RThread *th) { RIODesc *d = r_io_desc_get (r.io, r.file->fd); if (rabin_cmd && r_file_exists (d->name)) { char *nptr, *ptr, *cmd = r_sys_cmd_str (rabin_cmd, NULL, NULL); ptr = cmd; if (ptr) { do { if (th) { r_th_lock_enter (th->user); } nptr = strchr (ptr, '\n'); if (nptr) { *nptr = 0; } r_core_cmd (&r, ptr, 0); if (nptr) { ptr = nptr + 1; } if (th) { r_th_lock_leave (th->user); } } while (nptr); } //r_core_cmd (&r, cmd, 0); free (rabin_cmd); rabin_cmd = NULL; } if (th) { eprintf ("rabin2: done\n"); } return R_TH_STOP; }
static char* get_file_in_cur_dir(const char *filepath) { filepath = r_file_basename (filepath); if (r_file_exists (filepath) && !r_file_is_directory (filepath)) { return r_file_abspath (filepath); } return NULL; }
static int slurp_ruby(const char *file) { if (r_file_exists(file)) { rb_load_file(file); ruby_exec(); return R_TRUE; } eprintf("lang_ruby: Cannot open '%s'\n", file); return R_FALSE; }
static bool load_theme(RCore *core, const char *path) { if (!r_file_exists (path)) { return false; } core->cmdfilter = "ec "; bool res = r_core_cmd_file (core, path); if (res) { r_cons_pal_update_event (); } core->cmdfilter = NULL; return res; }
static Sdb *openDatabase(Sdb *db, const char *name) { char *file = r_str_newf ("%s/%s/%s.sdb", r_sys_prefix (NULL), "share/radare2/last", name); if (r_file_exists (file)) { if (db) { sdb_reset (db); sdb_open (db, file); } else { db = sdb_new (0, file, 0); } } free (file); return db; }
static int lang_c_file(RLang *lang, const char *file) { void *lib; char *cc, *p, name[512], buf[512]; const char *libpath, *libname; if (strlen (file) > (sizeof(name)-10)) return R_FALSE; if (!strstr (file, ".c")) sprintf (name, "%s.c", file); else strcpy (name, file); if (!r_file_exists (name)) { eprintf ("file not found (%s)\n", name); return R_FALSE; } { char *a = (char*)r_str_lchr (name, '/'); if (a) { *a = 0; libpath = name; libname = a+1; } else { libpath = "."; libname = name; } } p = strstr (name, ".c"); if (p) *p=0; cc = r_sys_getenv ("CC"); if (!cc || !*cc) cc = strdup ("gcc"); snprintf (buf, sizeof (buf), "%s -fPIC -shared %s -o %s/lib%s."R_LIB_EXT " $(pkg-config --cflags --libs r_core)", cc, file, libpath, libname); free (cc); if (r_sandbox_system (buf, 1) != 0) return R_FALSE; snprintf (buf, sizeof (buf), "%s/lib%s."R_LIB_EXT, libpath, libname); lib = r_lib_dl_open (buf); if (lib!= NULL) { void (*fcn)(RCore *); fcn = r_lib_dl_sym (lib, "entry"); if (fcn) fcn (lang->user); else eprintf ("Cannot find 'entry' symbol in library\n"); r_lib_dl_close (lib); } else eprintf ("Cannot open library\n"); r_file_rm (buf); // remove lib return 0; }
static Sdb *openDatabase(Sdb *db, const char *name) { #define SYSCALLPATH "/share/radare2/" R2_VERSION const char *file = sdb_fmt (0, "%s/%s/%s.sdb", r_sys_prefix (NULL), SYSCALLPATH, name); if (!r_file_exists (file)) { // eprintf ("r_syscall_setup: Cannot find '%s'\n", file); return false; } if (!db) { return sdb_new (0, file, 0); } sdb_reset (db); sdb_open (db, file); return db; }
ArchivoRegVars::ArchivoRegVars(char *url){ //ctor strcpy(&filename[0],url); if(r_file_exists()==1){ cout << "El archivo no existe!" << endl; if(r_create()==0){ cout << "El archivo ha sido creado con exito!" << endl; } else { cout << "Error al intentar crear el archivo!" << endl; salir("",ERROR_DE_CREACION); } } if(r_open("r+b")==0){ cout << "El archivo se ha abierto exitosamente!" << endl; } else { salir("",ERROR_DE_APERTURA); } }
static int r_vala_file(RLang *lang, const char *file) { void *lib; char *p, name[512], buf[512]; char *vapidir; if (!strstr (file, ".vala")) sprintf (name, "%s.vala", file); else strcpy (name, file); if (!r_file_exists (name)) { eprintf ("file not found (%s)\n", name); return R_FALSE; } vapidir = r_sys_getenv ("VAPIDIR"); if (vapidir) { if (*vapidir) { snprintf (buf, sizeof (buf), "valac --vapidir=%s --pkg r_core -C %s", vapidir, name); } free (vapidir); } else sprintf (buf, "valac --pkg r_core -C %s", name); if (system (buf) != 0) return R_FALSE; p = strstr (name, ".vala"); if (p) *p=0; p = strstr (name, ".gs"); if (p) *p=0; snprintf (buf, sizeof (buf), "gcc -fPIC -shared %s.c -o lib%s."R_LIB_EXT " $(pkg-config --cflags --libs r_core gobject-2.0)", name, name); if (system (buf) != 0) return R_FALSE; snprintf (buf, sizeof (buf), "./lib%s."R_LIB_EXT, name); lib = r_lib_dl_open (buf); if (lib!= NULL) { void (*fcn)(RCore *); fcn = r_lib_dl_sym (lib, "entry"); if (fcn) fcn (lang->user); else eprintf ("Cannot find 'entry' symbol in library\n"); r_lib_dl_close (lib); } else eprintf ("Cannot open library\n"); r_file_rm (buf); // remove lib sprintf (buf, "%s.c", name); // remove .c r_file_rm (buf); return 0; }
static int lang_cpipe_file(RLang *lang, const char *file) { char *a, *cc, *p, name[512]; const char *libpath, *libname; if (strlen (file) > (sizeof (name)-10)) return false; if (!strstr (file, ".c")) sprintf (name, "%s.c", file); else strcpy (name, file); if (!r_file_exists (name)) { eprintf ("file not found (%s)\n", name); return false; } a = (char*)r_str_lchr (name, '/'); if (a) { *a = 0; libpath = name; libname = a + 1; } else { libpath = "."; libname = name; } r_sys_setenv ("PKG_CONFIG_PATH", R2_LIBDIR"/pkgconfig"); p = strstr (name, ".c"); if (p) *p = 0; cc = r_sys_getenv ("CC"); if (!cc || !*cc) { free (cc); cc = strdup ("gcc"); } char *buf = r_str_newf ("%s %s -o %s/bin%s" " $(pkg-config --cflags --libs r_socket)", cc, file, libpath, libname); free (cc); if (r_sandbox_system (buf, 1) == 0) { char *binfile = r_str_newf ("%s/bin%s", libpath, libname); lang_pipe_run (lang, binfile, -1); r_file_rm (binfile); free (binfile); } free (buf); return 0; }
static char *find_include(const char *prefix, const char *file) { char *pfx = NULL, *ret = NULL, *env = r_sys_getenv (R_EGG_INCDIR_ENV); //eprintf ("find_include (%s,%s)\n", prefix, file); if (!prefix) prefix = ""; if (*prefix=='$') { char *out = r_sys_getenv (prefix+1); pfx = out? out: strdup (""); } else { pfx = strdup (prefix); if (!pfx) { free (env); return NULL; } } if (env) { char *str, *ptr = strchr (env, ':'); // eprintf ("MUST FIND IN PATH (%s)\n", env); str = env; while (str) { if (ptr) *ptr = 0; free (ret); ret = r_str_concatf (NULL, "%s/%s", pfx, file); { char *filepath = r_str_concatf (NULL, "%s/%s/%s", str, pfx, file); // eprintf ("try (%s)\n", filepath); if (r_file_exists (filepath)) { free (env); free (pfx); free (ret); return filepath; } free (filepath); } if (!ptr) break; str = ptr+1; ptr = strchr (str, ':'); } free (env); } else ret = r_str_concatf (NULL, "%s/%s", pfx, file); free (pfx); return ret; }
R_API bool r_core_is_project(RCore *core, const char *name) { bool ret = false; if (name && *name && *name != '.') { char *path = projectScriptPath (core, name); if (!path) { return false; } if (r_str_endswith (path, R_SYS_DIR "rc") && r_file_exists (path)) { ret = true; } else { path = r_str_append (path, ".d"); if (r_file_is_directory (path)) { ret = true; } } free (path); } return ret; }
R_API int r_syscall_setup(RSyscall *s, const char *arch, const char *os, int bits) { char file[256]; if (os == NULL) os = R_SYS_OS; if (arch == NULL) arch = R_SYS_ARCH; if (!strcmp (os, "any")) // ignored return R_TRUE; if (!strcmp (arch, "mips")) s->regs = fastcall_mips; else if (!strcmp (arch,"sh")) s->regs = fastcall_sh; else if (!strcmp (arch, "arm")) s->regs = fastcall_arm; else if (!strcmp (arch, "x86")) { switch (bits) { case 8: s->regs = fastcall_x86_8; case 32: s->regs = fastcall_x86_32; case 64: s->regs = fastcall_x86_64; } } #define SYSCALLPATH R2_LIBDIR"/radare2/"R2_VERSION"/syscall" snprintf (file, sizeof (file), "%s/%s-%s-%d.sdb", SYSCALLPATH, os, arch, bits); if (!r_file_exists (file)) { //eprintf ("r_syscall_setup: Cannot find '%s'\n", file); return R_FALSE; } // TODO: use sdb_reset (s->db); /// XXX: memoization doesnt seems to work because RSyscall is recreated instead of configured :( //eprintf ("DBG098: syscall->db must be reindexed for k\n"); sdb_free (s->db); s->db = sdb_new (0, file, 0); if (s->fd) fclose (s->fd); s->fd = NULL; return R_TRUE; }
R_API int r_syscall_setup(RSyscall *ctx, const char *arch, const char *os, int bits) { char file[256]; if (os == NULL) os = R_SYS_OS; if (arch == NULL) arch = R_SYS_ARCH; if (!strcmp (os, "any")) { // ignored return R_TRUE; } if (!strcmp (arch, "mips")) { ctx->regs = fastcall_mips; } else if (!strcmp (arch, "arm")) { ctx->regs = fastcall_arm; } else if (!strcmp (arch, "x86")) { ctx->regs = fastcall_x86; } else if (!strcmp (arch,"sh")) { ctx->regs = fastcall_sh; } #define SYSCALLPATH R2_LIBDIR"/radare2/"R2_VERSION"/syscall" snprintf (file, sizeof (file), "%s/%s-%s-%d.sdb", SYSCALLPATH, os, arch, bits); if (!r_file_exists (file)) { //eprintf ("r_syscall_setup: Cannot find '%s'\n", file); return R_FALSE; } r_pair_free (ctx->syspair); ctx->syspair = r_pair_new_from_file (file); if (ctx->fd) fclose (ctx->fd); ctx->fd = NULL; return R_TRUE; }
R_API char* r_egg_Cfile_parser(const char *file, const char *arch, const char *os, int bits) { char *output = NULL; char *fileExt = NULL; // "file" with extension (.s, .text, ...) struct cEnv_t *cEnv = r_egg_Cfile_set_cEnv (arch, os, bits); if (!cEnv) { goto fail; } r_str_sanitize (cEnv->CC); //printf ("==> Compile\n"); printf ("'%s' %s -o '%s.tmp' -S -Os '%s'\n", cEnv->CC, cEnv->CFLAGS, file, file); output = r_sys_cmd_strf ("('%s' %s -o '%s.tmp' -S -Os '%s') 2>&1", cEnv->CC, cEnv->CFLAGS, file, file); if (output == NULL) { eprintf ("Compilation failed!\n"); goto fail; } printf ("%s", output); if (!(fileExt = r_str_newf ("%s.s", file))) { goto fail; } if (!r_file_dump (fileExt, (const ut8*) cEnv->SHDR, strlen (cEnv->SHDR), false)) { eprintf ("Error while opening %s.s\n", file); goto fail; } if (!r_egg_Cfile_parseCompiled (file)) { goto fail; } //printf ("==> Assemble\n"); printf ("'%s' %s -Os -o '%s.o' '%s.s'\n", cEnv->CC, cEnv->LDFLAGS, file, file); free (output); output = r_sys_cmd_strf ("'%s' %s -Os -o '%s.o' '%s.s'", cEnv->CC, cEnv->LDFLAGS, file, file); if (!output) { eprintf ("Assembly failed!\n"); goto fail; } printf ("%s", output); //printf ("==> Link\n"); printf ("rabin2 -o '%s.text' -O d/S/'%s' '%s.o'\n", file, cEnv->TEXT, file); free (output); output = r_sys_cmd_strf ("rabin2 -o '%s.text' -O d/S/'%s' '%s'.o", file, cEnv->TEXT, file); if (!output) { eprintf ("Linkage failed!\n"); goto fail; } free (fileExt); if (!(fileExt = r_str_newf ("%s.o", file))) { goto fail; } if (!r_file_exists (fileExt)) { eprintf ("Cannot find %s.o\n", file); goto fail; } free (fileExt); if (!(fileExt = r_str_newf ("%s.text", file))) { goto fail; } if (r_file_size (fileExt) == 0) { printf ("FALLBACK: Using objcopy instead of rabin2"); free (output); output = r_sys_cmd_strf ("'%s' -j .text -O binary '%s.o' '%s.text'", cEnv->OBJCOPY, file, file); if (!output) { eprintf ("objcopy failed!\n"); goto fail; } } size_t i; const char *extArray[] = {"bin", "tmp", "s", "o"}; for (i = 0; i < 4; i++) { free (fileExt); if (!(fileExt = r_str_newf ("%s.%s", file, extArray[i]))) { goto fail; } r_file_rm (fileExt); } free (fileExt); if ((fileExt = r_str_newf ("%s.text", file)) == NULL) { goto fail; } free (output); r_egg_Cfile_free_cEnv (cEnv); return fileExt; fail: free (fileExt); free (output); r_egg_Cfile_free_cEnv (cEnv); return NULL; }
static int lang_vala_file(RLang *lang, const char *file, bool silent) { void *lib; char *p, name[512], buf[512]; char *vapidir, *srcdir, *libname; if (strlen (file)>500) return false; if (!strstr (file, ".vala")) sprintf (name, "%s.vala", file); else strcpy (name, file); if (!r_file_exists (name)) { eprintf ("file not found (%s)\n", name); return false; } srcdir = strdup (file); p = (char*)r_str_lchr (srcdir, '/'); if (p) { *p = 0; libname = strdup (p+1); if (*file!='/') { strcpy (srcdir, "."); } } else { libname = strdup (file); strcpy (srcdir, "."); } r_sys_setenv ("PKG_CONFIG_PATH", R2_LIBDIR"/pkgconfig"); vapidir = r_sys_getenv ("VAPIDIR"); char *tail = silent? " > /dev/null 2>&1": ""; if (vapidir) { if (*vapidir) { snprintf (buf, sizeof (buf)-1, "valac -d %s --vapidir=%s --pkg r_core -C %s %s", srcdir, vapidir, name, tail); } free (vapidir); } else { snprintf (buf, sizeof (buf) - 1, "valac -d %s --pkg r_core -C %s %s", srcdir, name, tail); } free (srcdir); if (r_sandbox_system (buf, 1) != 0) { free (libname); return false; } p = strstr (name, ".vala"); if (p) *p=0; p = strstr (name, ".gs"); if (p) *p=0; // TODO: use CC environ if possible snprintf (buf, sizeof (buf), "gcc -fPIC -shared %s.c -o lib%s."R_LIB_EXT " $(pkg-config --cflags --libs r_core gobject-2.0)", name, libname); if (r_sandbox_system (buf, 1) != 0) { free (libname); return false; } snprintf (buf, sizeof (buf), "./lib%s."R_LIB_EXT, libname); free (libname); lib = r_lib_dl_open (buf); if (lib != NULL) { void (*fcn)(RCore *); fcn = r_lib_dl_sym (lib, "entry"); if (fcn) fcn (lang->user); else eprintf ("Cannot find 'entry' symbol in library\n"); r_lib_dl_close (lib); } else eprintf ("Cannot open library\n"); r_file_rm (buf); // remove lib sprintf (buf, "%s.c", name); // remove .c r_file_rm (buf); return 0; }
static int runfile () { if (!_program) { printf ("No program rule defined\n"); return 1; } if (_stdin) { int f = open (_stdin, O_RDONLY); close (0); dup2 (f, 0); } if (_stdout) { int f = open (_stdout, O_RDONLY); close (1); dup2 (f, 1); } if (_stderr) { int f = open (_stderr, O_RDONLY); close (2); dup2 (f, 2); } if (_connect) { char *p = strchr (_connect, ':'); if (p) { RSocket *fd = r_socket_new (0); *p=0; if (!r_socket_connect_tcp (fd, _connect, p+1, 30)) { eprintf ("Cannot connect\n"); return 1; } eprintf ("connected\n"); close (0); close (1); close (2); dup2 (fd->fd, 0); dup2 (fd->fd, 1); dup2 (fd->fd, 2); } else { eprintf ("Invalid format for connect. missing ':'\n"); return 1; } } if (_listen) { RSocket *child, *fd = r_socket_new (0); if (!r_socket_listen (fd, _listen, NULL)) { eprintf ("rarun2: cannot listen\n"); return 1; } child = r_socket_accept (fd); if (child) { eprintf ("connected\n"); close (0); close (1); close (2); dup2 (child->fd, 0); dup2 (child->fd, 1); dup2 (child->fd, 2); } } if (_chgdir) chdir (_chgdir); if (_chroot) chdir (_chroot); #if __UNIX__ if (_chroot) { if (chroot (".")) { eprintf ("rarun2: cannot chroot\n"); return 1; } } if (_setuid) setuid (atoi (_setuid)); if (_seteuid) seteuid (atoi (_seteuid)); if (_setgid) setgid (atoi (_setgid)); if (_input) { int f2[2]; pipe (f2); close (0); dup2 (f2[0], 0); parseinput (_input); write (f2[1], _input, strlen (_input)); } #endif if (_preload) { #if __APPLE__ r_sys_setenv ("DYLD_PRELOAD", _preload); #else r_sys_setenv ("LD_PRELOAD", _preload); #endif } if (_timeout) { #if __UNIX__ int mypid = getpid (); if (!fork ()) { sleep (_timeout); if (!kill (mypid, 0)) fprintf (stderr, "\nrarun2: Interrupted by timeout\n"); kill (mypid, SIGKILL); exit (0); } #else eprintf ("timeout not supported for this platform\n"); #endif } if (!r_file_exists (_program)) { eprintf ("rarun2: %s: file not found\n", _program); return 1; } exit (execv (_program, _args)); }
R_API int r_run_start(RRunProfile *p) { #if LIBC_HAVE_FORK if (p->_execve) { exit (execv (p->_program, (char* const*)p->_args)); } #endif #if __APPLE__ && !__POWERPC__ && LIBC_HAVE_FORK posix_spawnattr_t attr = {0}; pid_t pid = -1; int ret; posix_spawnattr_init (&attr); if (p->_args[0]) { char **envp = r_sys_get_environ(); ut32 spflags = 0; //POSIX_SPAWN_START_SUSPENDED; spflags |= POSIX_SPAWN_SETEXEC; if (p->_aslr == 0) { #define _POSIX_SPAWN_DISABLE_ASLR 0x0100 spflags |= _POSIX_SPAWN_DISABLE_ASLR; } (void)posix_spawnattr_setflags (&attr, spflags); if (p->_bits) { size_t copied = 1; cpu_type_t cpu; #if __i386__ || __x86_64__ cpu = CPU_TYPE_I386; if (p->_bits == 64) { cpu |= CPU_ARCH_ABI64; } #else cpu = CPU_TYPE_ANY; #endif posix_spawnattr_setbinpref_np ( &attr, 1, &cpu, &copied); } ret = posix_spawnp (&pid, p->_args[0], NULL, &attr, p->_args, envp); switch (ret) { case 0: break; case 22: eprintf ("posix_spawnp: Invalid argument\n"); break; case 86: eprintf ("posix_spawnp: Unsupported architecture\n"); break; default: eprintf ("posix_spawnp: unknown error %d\n", ret); perror ("posix_spawnp"); break; } exit (ret); } #endif if (p->_system) { if (p->_pid) { eprintf ("PID: Cannot determine pid with 'system' directive. Use 'program'.\n"); } exit (r_sys_cmd (p->_system)); } if (p->_program) { if (!r_file_exists (p->_program)) { char *progpath = r_file_path (p->_program); if (progpath && *progpath) { free (p->_program); p->_program = progpath; } else { free (progpath); eprintf ("rarun2: %s: file not found\n", p->_program); return 1; } } #if __UNIX__ // XXX HACK close all non-tty fds { int i; for (i = 3; i < 10; i++) { close (i); } } // TODO: use posix_spawn if (p->_setgid) { int ret = setgid (atoi (p->_setgid)); if (ret < 0) { return 1; } } if (p->_pid) { eprintf ("PID: %d\n", getpid ()); } if (p->_pidfile) { char pidstr[32]; snprintf (pidstr, sizeof (pidstr), "%d\n", getpid ()); r_file_dump (p->_pidfile, (const ut8*)pidstr, strlen (pidstr), 0); } #endif if (p->_nice) { #if __UNIX__ && !defined(__HAIKU__) if (nice (p->_nice) == -1) { return 1; } #else eprintf ("nice not supported for this platform\n"); #endif } // TODO: must be HAVE_EXECVE #if LIBC_HAVE_FORK exit (execv (p->_program, (char* const*)p->_args)); #endif } if (p->_runlib) { if (!p->_runlib_fcn) { eprintf ("No function specified. Please set runlib.fcn\n"); return 1; } void *addr = r_lib_dl_open (p->_runlib); if (!addr) { eprintf ("Could not load the library '%s'\n", p->_runlib); return 1; } void (*fcn)(void) = r_lib_dl_sym (addr, p->_runlib_fcn); if (!fcn) { eprintf ("Could not find the function '%s'\n", p->_runlib_fcn); return 1; } switch (p->_argc) { case 0: fcn (); break; case 1: r_run_call1 (fcn, p->_args[1]); break; case 2: r_run_call2 (fcn, p->_args[1], p->_args[2]); break; case 3: r_run_call3 (fcn, p->_args[1], p->_args[2], p->_args[3]); break; case 4: r_run_call4 (fcn, p->_args[1], p->_args[2], p->_args[3], p->_args[4]); break; case 5: r_run_call5 (fcn, p->_args[1], p->_args[2], p->_args[3], p->_args[4], p->_args[5]); break; case 6: r_run_call6 (fcn, p->_args[1], p->_args[2], p->_args[3], p->_args[4], p->_args[5], p->_args[6]); break; case 7: r_run_call7 (fcn, p->_args[1], p->_args[2], p->_args[3], p->_args[4], p->_args[5], p->_args[6], p->_args[7]); break; case 8: r_run_call8 (fcn, p->_args[1], p->_args[2], p->_args[3], p->_args[4], p->_args[5], p->_args[6], p->_args[7], p->_args[8]); break; case 9: r_run_call9 (fcn, p->_args[1], p->_args[2], p->_args[3], p->_args[4], p->_args[5], p->_args[6], p->_args[7], p->_args[8], p->_args[9]); break; case 10: r_run_call10 (fcn, p->_args[1], p->_args[2], p->_args[3], p->_args[4], p->_args[5], p->_args[6], p->_args[7], p->_args[8], p->_args[9], p->_args[10]); break; default: eprintf ("Too many arguments.\n"); return 1; } r_lib_dl_close (addr); } return 0; }
R_API int r_run_start(RRunProfile *p) { #if __APPLE__ posix_spawnattr_t attr = {0}; pid_t pid = -1; #endif int ret; if (!p->_program && !p->_system) { printf ("No program or system rule defined\n"); return 1; } if (p->_stdin) { int f = open (p->_stdin, O_RDONLY); if (f < 0) return 1; close (0); dup2 (f, 0); } if (p->_stdout) { int f = open (p->_stdout, O_WRONLY); if (f < 0) return 1; close (1); dup2 (f, 1); } if (p->_stderr) { int f = open (p->_stderr, O_WRONLY); if (f < 0) return 1; close (2); dup2 (f, 2); } if (p->_aslr != -1) setASLR (p->_aslr); #if __UNIX__ set_limit (p->_docore, RLIMIT_CORE, RLIM_INFINITY); if (p->_maxfd) set_limit (p->_maxfd, RLIMIT_NOFILE, p->_maxfd); #ifdef RLIMIT_NPROC if (p->_maxproc) set_limit (p->_maxproc, RLIMIT_NPROC, p->_maxproc); #endif if (p->_maxstack) set_limit (p->_maxstack, RLIMIT_STACK, p->_maxstack); #else if (p->_docore || p->_maxfd || p->_maxproc || p->_maxstack) eprintf ("Warning: setrlimits not supported for this platform\n"); #endif if (p->_connect) { char *q = strchr (p->_connect, ':'); if (q) { RSocket *fd = r_socket_new (0); *q = 0; if (!r_socket_connect_tcp (fd, p->_connect, q+1, 30)) { eprintf ("Cannot connect\n"); return 1; } eprintf ("connected\n"); close (0); close (1); close (2); dup2 (fd->fd, 0); dup2 (fd->fd, 1); dup2 (fd->fd, 2); } else { eprintf ("Invalid format for connect. missing ':'\n"); return 1; } } if (p->_listen) { RSocket *child, *fd = r_socket_new (0); if (!r_socket_listen (fd, p->_listen, NULL)) { eprintf ("rarun2: cannot listen\n"); r_socket_free (fd); return 1; } child = r_socket_accept (fd); if (child) { eprintf ("connected\n"); close (0); close (1); close (2); dup2 (child->fd, 0); dup2 (child->fd, 1); dup2 (child->fd, 2); } } if (p->_r2sleep != 0) { r_sys_sleep (p->_r2sleep); } if (p->_chgdir) { ret = chdir (p->_chgdir); if (ret < 0) return 1; } if (p->_chroot) { ret = chdir (p->_chroot); if (ret < 0) return 1; } #if __UNIX__ if (p->_chroot) { if (chroot (p->_chroot)) { eprintf ("rarun2: cannot chroot\n"); return 1; } chdir("/"); } if (p->_setuid) { ret = setgroups(0, NULL); if (ret < 0) return 1; ret = setuid (atoi (p->_setuid)); if (ret < 0) return 1; } if (p->_seteuid) { ret = seteuid (atoi (p->_seteuid)); if (ret < 0) return 1; } if (p->_setgid) { ret = setgid (atoi (p->_setgid)); if (ret < 0) return 1; } if (p->_input) { int f2[2]; pipe (f2); close (0); dup2 (f2[0], 0); parseinput (p->_input); write (f2[1], p->_input, strlen (p->_input)); } #endif if (p->_r2preload) { if (p->_preload) { eprintf ("WARNING: Only one library can be opened at a time\n"); } p->_preload = R2_LIBDIR"/libr2."R_LIB_EXT; } if (p->_libpath) { #if __WINDOWS__ eprintf ("rarun2: libpath unsupported for this platform\n"); #elif __HAIKU__ r_sys_setenv ("LIBRARY_PATH", p->_libpath); #elif __APPLE__ r_sys_setenv ("DYLD_LIBRARY_PATH", p->_libpath); #else r_sys_setenv ("LD_LIBRARY_PATH", p->_libpath); #endif } if (p->_preload) { #if __APPLE__ // 10.6 r_sys_setenv ("DYLD_PRELOAD", p->_preload); r_sys_setenv ("DYLD_INSERT_LIBRARIES", p->_preload); // 10.8 r_sys_setenv ("DYLD_FORCE_FLAT_NAMESPACE", "1"); #else r_sys_setenv ("LD_PRELOAD", p->_preload); #endif } if (p->_timeout) { #if __UNIX__ int mypid = getpid (); if (!fork ()) { sleep (p->_timeout); if (!kill (mypid, 0)) eprintf ("\nrarun2: Interrupted by timeout\n"); kill (mypid, SIGKILL); exit (0); } #else eprintf ("timeout not supported for this platform\n"); #endif } #if __APPLE__ posix_spawnattr_init (&attr); if (p->_args[0]) { char **envp = r_sys_get_environ(); ut32 spflags = 0; //POSIX_SPAWN_START_SUSPENDED; spflags |= POSIX_SPAWN_SETEXEC; if (p->_aslr == 0) { #define _POSIX_SPAWN_DISABLE_ASLR 0x0100 spflags |= _POSIX_SPAWN_DISABLE_ASLR; } (void)posix_spawnattr_setflags (&attr, spflags); if (p->_bits) { size_t copied = 1; cpu_type_t cpu; #if __i386__ || __x86_64__ cpu = CPU_TYPE_I386; if (p->_bits == 64) cpu |= CPU_ARCH_ABI64; #else cpu = CPU_TYPE_ANY; #endif posix_spawnattr_setbinpref_np ( &attr, 1, &cpu, &copied); } ret = posix_spawnp (&pid, p->_args[0], NULL, &attr, p->_args, envp); switch (ret) { case 0: break; case 22: eprintf ("posix_spawnp: Invalid argument\n"); break; case 86: eprintf ("posix_spawnp: Unsupported architecture\n"); break; default: eprintf ("posix_spawnp: unknown error %d\n", ret); perror ("posix_spawnp"); break; } exit (ret); } #endif if (p->_system) { if (p->_pid) { eprintf ("PID: Cannot determine pid with 'system' directive. Use 'program'.\n"); } exit (r_sys_cmd (p->_system)); } if (p->_program) { if (!r_file_exists (p->_program)) { char *progpath = r_file_path (p->_program); if (progpath && *progpath) { free (p->_program); p->_program = progpath; } else { free (progpath); eprintf ("rarun2: %s: file not found\n", p->_program); return 1; } } #if __UNIX__ // XXX HACK close all non-tty fds { int i; for (i=3; i<10; i++) close (i); } // TODO: use posix_spawn if (p->_setgid) { ret = setgid (atoi (p->_setgid)); if (ret < 0) return 1; } if (p->_pid) { eprintf ("PID: %d\n", getpid ()); } if (p->_pidfile) { char pidstr[32]; snprintf (pidstr, sizeof (pidstr), "%d\n", getpid ()); r_file_dump (p->_pidfile, (const ut8*)pidstr, strlen (pidstr), 0); } #endif if (p->_nice) { #if __UNIX__ errno = 0; ret = nice(p->_nice); if (ret == -1) { if (errno != 0) { return 1; } } #else eprintf ("nice not supported for this platform\n"); #endif } exit (execv (p->_program, (char* const*)p->_args)); } return 0; }
R_API bool r_syscall_setup(RSyscall *s, const char *arch, const char *os, int bits) { const char *file; if (!os || !*os) { os = R_SYS_OS; } if (!arch) { arch = R_SYS_ARCH; } free (s->os); s->os = strdup (os); if (!strcmp (os, "any")) { // ignored return true; } if (!strcmp (arch, "mips")) { s->regs = fastcall_mips; } else if (!strcmp (arch,"avr")) { s->sysport = sysport_avr; } else if (!strcmp (arch,"sh")) { s->regs = fastcall_sh; } else if (!strcmp (arch, "arm")) { switch (bits) { case 16: case 32: s->regs = fastcall_arm; break; case 64: s->regs = fastcall_arm64; break; } } else if (!strcmp (arch, "x86")) { s->sysport = sysport_x86; switch (bits) { case 8: s->regs = fastcall_x86_8; break; case 32: s->regs = fastcall_x86_32; break; case 64: s->regs = fastcall_x86_64; break; } } #define SYSCALLPATH R2_PREFIX "/share/radare2/" R2_VERSION "/syscall" file = sdb_fmt (0, "%s/%s-%s-%d.sdb", SYSCALLPATH, os, arch, bits); if (!r_file_exists (file)) { // eprintf ("r_syscall_setup: Cannot find '%s'\n", file); return false; } //eprintf ("DBG098: syscall->db must be reindexed for k\n"); sdb_close (s->db); sdb_reset (s->db); sdb_open (s->db, file); // s->db = sdb_new (0, file, 0); #if 1 if (s->fd) { fclose (s->fd); } s->fd = NULL; #endif return true; }
static int runfile () { if (!_program && !_system) { printf ("No program or system rule defined\n"); return 1; } if (_stdin) { int f = open (_stdin, O_RDONLY); close (0); dup2 (f, 0); } if (_stdout) { int f = open (_stdout, O_WRONLY); close (1); dup2 (f, 1); } if (_stderr) { int f = open (_stderr, O_WRONLY); close (2); dup2 (f, 2); } if (_connect) { char *p = strchr (_connect, ':'); if (p) { RSocket *fd = r_socket_new (0); *p=0; if (!r_socket_connect_tcp (fd, _connect, p+1, 30)) { eprintf ("Cannot connect\n"); return 1; } eprintf ("connected\n"); close (0); close (1); close (2); dup2 (fd->fd, 0); dup2 (fd->fd, 1); dup2 (fd->fd, 2); } else { eprintf ("Invalid format for connect. missing ':'\n"); return 1; } } if (_listen) { RSocket *child, *fd = r_socket_new (0); if (!r_socket_listen (fd, _listen, NULL)) { eprintf ("rarun2: cannot listen\n"); return 1; } child = r_socket_accept (fd); if (child) { eprintf ("connected\n"); close (0); close (1); close (2); dup2 (child->fd, 0); dup2 (child->fd, 1); dup2 (child->fd, 2); } } if (_chgdir) chdir (_chgdir); if (_chroot) chdir (_chroot); #if __UNIX__ if (_chroot) { if (chroot (".")) { eprintf ("rarun2: cannot chroot\n"); return 1; } } if (_setuid) setuid (atoi (_setuid)); if (_seteuid) seteuid (atoi (_seteuid)); if (_setgid) setgid (atoi (_setgid)); if (_input) { int f2[2]; pipe (f2); close (0); dup2 (f2[0], 0); parseinput (_input); write (f2[1], _input, strlen (_input)); } #endif if (_r2preload) { if (_preload) { eprintf ("WARNING: Only one library can be opened at a time\n"); } _preload = R2_LIBDIR"/libr2."R_LIB_EXT; } if (_libpath) { #if __WINDOWS__ eprintf ("rarun2: libpath unsupported for this platform\n"); #elif __APPLE__ r_sys_setenv ("DYLD_LIBRARY_PATH", _libpath); #else r_sys_setenv ("LD_LIBRARY_PATH", _libpath); #endif } if (_preload) { #if __APPLE__ // 10.6 r_sys_setenv ("DYLD_PRELOAD", _preload); r_sys_setenv ("DYLD_INSERT_LIBRARIES", _preload); // 10.8 r_sys_setenv ("DYLD_FORCE_FLAT_NAMESPACE", "1"); #else r_sys_setenv ("LD_PRELOAD", _preload); #endif } if (_timeout) { #if __UNIX__ int mypid = getpid (); if (!fork ()) { sleep (_timeout); if (!kill (mypid, 0)) eprintf ("\nrarun2: Interrupted by timeout\n"); kill (mypid, SIGKILL); exit (0); } #else eprintf ("timeout not supported for this platform\n"); #endif } if (_system) { exit (r_sys_cmd (_system)); } if (!r_file_exists (_program)) { eprintf ("rarun2: %s: file not found\n", _program); return 1; } exit (execv (_program, _args)); }
static int cmd_type(void *data, const char *input) { RCore *core = (RCore *)data; switch (input[0]) { // t [typename] - show given type in C syntax case 'u': // "tu" switch (input[1]) { case '?': { const char *help_message[] = { "USAGE tu[...]", "", "", "tu", "", "List all loaded unions", "tu?", "", "show this help", NULL }; r_core_cmd_help (core, help_message); } break; case 0: sdb_foreach (core->anal->sdb_types, stdprintifunion, core); break; } break; case 'k': // "tk" if (input[1] == ' ') { sdb_query (core->anal->sdb_types, input + 2); } else sdb_query (core->anal->sdb_types, "*"); fflush (stdout); break; case 's': // "ts" switch (input[1]) { case '?': { const char *help_message[] = { "USAGE ts[...]", "", "", "ts", "", "List all loaded structs", "ts?", "", "show this help", NULL }; r_core_cmd_help (core, help_message); } break; case 0: sdb_foreach (core->anal->sdb_types, stdprintifstruct, core); break; } break; case 'b': { char *p, *s = (strlen (input) > 1)? strdup (input + 2): NULL; const char *isenum; p = s? strchr (s, ' '): NULL; if (p) { *p++ = 0; // dupp in core.c (see getbitfield()) isenum = sdb_const_get (core->anal->sdb_types, s, 0); if (isenum && !strcmp (isenum, "enum")) { *--p = '.'; const char *res = sdb_const_get (core->anal->sdb_types, s, 0); if (res) r_cons_println (res); else eprintf ("Invalid enum member\n"); } else { eprintf ("This is not an enum\n"); } } else { eprintf ("Missing value\n"); } free (s); } break; case 'e': { if (!input[1]) { char *name = NULL; SdbKv *kv; SdbListIter *iter; SdbList *l = sdb_foreach_list (core->anal->sdb_types); ls_foreach (l, iter, kv) { if (!strcmp (kv->value, "enum")) { if (!name || strcmp (kv->value, name)) { free (name); name = strdup (kv->key); r_cons_println (name); } } } free (name); ls_free (l); break; } if (input[1] == '?') { const char *help_message[] = { "USAGE te[...]", "", "", "te", "", "List all loaded enums", "te", " <enum> <value>", "Show name for given enum number", "te?", "", "show this help", NULL }; r_core_cmd_help (core, help_message); break; } char *p, *s = strdup (input + 2); const char *isenum; p = strchr (s, ' '); if (p) { *p++ = 0; isenum = sdb_const_get (core->anal->sdb_types, s, 0); if (isenum && !strncmp (isenum, "enum", 4)) { const char *q = sdb_fmt (0, "%s.0x%x", s, (ut32)r_num_math (core->num, p)); const char *res = sdb_const_get (core->anal->sdb_types, q, 0); if (res) r_cons_println (res); } else { eprintf ("This is not an enum\n"); } } else { //eprintf ("Missing value\n"); r_core_cmdf (core, "t~&%s,=0x", s); } free (s); } break; case ' ': { const char *isenum = sdb_const_get (core->anal->sdb_types, input + 1, 0); if (isenum && !strcmp (isenum, "enum")) { eprintf ("IS ENUM! \n"); } else { char *fmt = r_anal_type_format (core->anal, input + 1); if (fmt) { r_str_chop (fmt); r_cons_printf ("pf %s\n", fmt); free (fmt); } else eprintf ("Cannot find '%s' type\n", input + 1); } } break; // t* - list all types in 'pf' syntax case '*': sdb_foreach (core->anal->sdb_types, typelist, core); break; case 0: sdb_foreach (core->anal->sdb_types, sdbforcb, core); break; case 'o': if (!r_sandbox_enable (0)) { if (input[1] == ' ') { const char *filename = input + 2; char *homefile = NULL; if (*filename == '~') { if (filename[1] && filename[2]) { homefile = r_str_home (filename + 2); filename = homefile; } } if (!strcmp (filename, "-")) { char *out, *tmp; tmp = r_core_editor (core, NULL, ""); if (tmp) { out = r_parse_c_string (tmp); if (out) { // r_cons_strcat (out); save_parsed_type (core, out); free (out); } free (tmp); } } else { char *out = r_parse_c_file (filename); if (out) { //r_cons_strcat (out); save_parsed_type (core, out); free (out); } //r_anal_type_loadfile (core->anal, filename); } free (homefile); } else if (input[1] == 's') { const char *dbpath = input + 3; if (r_file_exists (dbpath)) { Sdb *db_tmp = sdb_new (0, dbpath, 0); sdb_merge (core->anal->sdb_types, db_tmp); sdb_close (db_tmp); sdb_free (db_tmp); } } } else { eprintf ("Sandbox: system call disabled\n"); } break; // td - parse string with cparse engine and load types from it case 'd': if (input[1] == '?') { const char *help_message[] = { "Usage:", "\"td [...]\"", "", "td", "[string]", "Load types from string", NULL }; r_core_cmd_help (core, help_message); r_cons_printf ("Note: The td command should be put between double quotes\n" "Example: \" td struct foo {int bar;int cow};\"" "\nt"); } else if (input[1] == ' ') { char tmp[8192]; snprintf (tmp, sizeof (tmp) - 1, "%s;", input + 2); //const char *string = input + 2; //r_anal_str_to_type (core->anal, string); char *out = r_parse_c_string (tmp); if (out) { //r_cons_strcat (out); save_parsed_type (core, out); free (out); } } else { eprintf ("Invalid use of td. See td? for help\n"); } break; // tl - link a type to an address case 'l': switch (input[1]) { case '?': { const char *help_message[] = { "Usage:", "", "", "tl", "", "list all links in readable format", "tl", "[typename]", "link a type to current adress.", "tl", "[typename] = [address]", "link type to given address.", "tls", "[address]", "show link at given address", "tl-*", "", "delete all links.", "tl-", "[address]", "delete link at given address.", "tl*", "", "list all links in radare2 command format", "tl?", "", "print this help.", NULL }; r_core_cmd_help (core, help_message); } break; case ' ': { char *type = strdup (input + 2); char *ptr = strchr (type, '='); ut64 addr; if (ptr) { *ptr++ = 0; r_str_chop (ptr); if (ptr && *ptr) { addr = r_num_math (core->num, ptr); } else { eprintf ("address is unvalid\n"); free (type); break; } } else { addr = core->offset; } r_str_chop (type); char *tmp = sdb_get (core->anal->sdb_types, type, 0); if (tmp && *tmp) { r_anal_type_link (core->anal, type, addr); free (tmp); } else { eprintf ("unknown type %s\n", type); } free (type); } break; case 's': { int ptr; char *addr = strdup (input + 2); SdbKv *kv; SdbListIter *sdb_iter; SdbList *sdb_list = sdb_foreach_list (core->anal->sdb_types); r_str_chop (addr); ptr = r_num_math (NULL, addr); //r_core_cmdf (core, "tl~0x%08"PFMT64x" = ", addr); ls_foreach (sdb_list, sdb_iter, kv) { char *linkptr; if (strncmp (kv->key, "link.", strlen ("link."))) { continue; } linkptr = sdb_fmt (-1,"0x%s", kv->key + strlen ("link.")); if (ptr == r_num_math (NULL, linkptr)) { linklist_readable (core, kv->key, kv->value); } } free (addr); ls_free (sdb_list); } break; case '-': switch (input[2]) { case '*': sdb_foreach (core->anal->sdb_types, sdbdeletelink, core); break; case ' ': { const char *ptr = input + 3; ut64 addr = r_num_math (core->num, ptr); r_anal_type_unlink (core->anal, addr); } break; } break; case '*': sdb_foreach (core->anal->sdb_types, linklist, core); break; case '\0': sdb_foreach (core->anal->sdb_types, linklist_readable, core); break; }