diff --git a/libr/debug/p/native/linux/linux_debug.c b/libr/debug/p/native/linux/linux_debug.c index 5a5a5a6c81..3ff6436f5d 100644 --- a/libr/debug/p/native/linux/linux_debug.c +++ b/libr/debug/p/native/linux/linux_debug.c @@ -1337,12 +1337,11 @@ RList *linux_desc_list(int pid) { r_sys_perror ("readlink failure"); return NULL; } - free (fn); buf[sizeof (buf) - 1] = 0; type = perm = 0; // Read file type - if (stat (fd_file, &st) != -1) { + if (stat (fn, &st) != -1) { bool isfifo = st.st_mode & S_IFIFO; #ifdef S_IFSOCK /* Do *not* remove the == here. S_IFSOCK can be multiple @@ -1363,7 +1362,7 @@ RList *linux_desc_list(int pid) { } } // Read permissions - if (lstat (fd_file, &st) != -1) { + if (lstat (fn, &st) != -1) { if (st.st_mode & S_IRUSR) { perm |= R_PERM_R; } @@ -1371,21 +1370,25 @@ RList *linux_desc_list(int pid) { perm |= R_PERM_W; } } - // Get offset - char *fn = r_str_newf ("/proc/%d/fdinfo/%s", pid, de->d_name) >= sizeof (fdinfo_file)) { - f = open (fn, O_RDONLY); - char fdinfo[512]; - if (read (f, fdinfo, sizeof (fdinfo) - 1) < 0) { - R_WARN ("failed to read %s\n", fn); - close (f); - r_list_free (ret); - closedir (dd); - free (fn); - return NULL; - } free (fn); - fdinfo[sizeof (fdinfo) - 1] = '\0'; - close (f); + // Get offset + fn = r_str_newf ("/proc/%d/fdinfo/%s", pid, de->d_name); + int f = open (fn, O_RDONLY); + char fdinfo[512]; + fdinfo[0] = 0; + if (f >= 0) { + if (read (f, fdinfo, sizeof (fdinfo) - 1) < 0) { + R_LOG_WARN ("failed to read %s", fn); + close (f); + r_list_free (ret); + closedir (dd); + free (fn); + return NULL; + } + free (fn); + fdinfo[sizeof (fdinfo) - 1] = '\0'; + close (f); + } /* First line of fdinfo is "pos: [offset]" */ ut64 offset = (int) r_num_math (NULL, r_str_trim_head_ro (fdinfo + 4)); RDebugDesc *desc = r_debug_desc_new (atoi (de->d_name), buf, perm, type, offset); diff --git a/libr/util/log.c b/libr/util/log.c index ba67cfb8fd..f081115a0f 100644 --- a/libr/util/log.c +++ b/libr/util/log.c @@ -10,7 +10,7 @@ static const char *level_tags[] = { // Log level to tag string lookup array [R_LOGLVL_ERROR] = "ERROR", [R_LOGLVL_INFO] = "INFO", [R_LOGLVL_WARN] = "WARN", - [R_LOGLVL_DEBUG] = "DEBG", + [R_LOGLVL_DEBUG] = "DEBUG", }; static const char *level_name(int i) { @@ -133,14 +133,14 @@ R_API void r_log_vmessage(RLogLevel level, const char *origin, const char *fmt, default: break; } - r_strbuf_appendf (sb, "%s[%s] ", k, level_name (level)); + r_strbuf_appendf (sb, "%s%s: ", k, level_name (level)); if (rlog->show_origin) { r_strbuf_appendf (sb, Color_YELLOW "[%s] " Color_RESET, origin); } else { r_strbuf_appendf (sb, Color_RESET); } } else { - r_strbuf_appendf (sb, "[%s] ", level_name (level)); + r_strbuf_appendf (sb, "%s: ", level_name (level)); if (rlog->show_origin) { r_strbuf_appendf (sb, "[%s] ", origin); } diff --git a/test/db/cmd/cmd_i b/test/db/cmd/cmd_i index 39b1656dbb..87be51fd58 100644 --- a/test/db/cmd/cmd_i +++ b/test/db/cmd/cmd_i @@ -3312,7 +3312,7 @@ RUN NAME=i (no rbin - file x86_64) FILE=bins/elf/analysis/hello-linux-x86_64 -ARGS=-n +ARGS=-n -a x86 -b 64 CMDS=i~!file EXPECT=<