Fix build and tests

* Fix one x86-64-specific test to pass everywhere
This commit is contained in:
pancake 2022-04-21 23:11:42 +00:00 committed by pancake
parent 9b7cbc9cf7
commit 4823451497
4 changed files with 27 additions and 24 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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=<<EOF
fd 3
@ -4154,7 +4154,7 @@ format elf
bintype elf
EOF
EXPECT_ERR=<<EOF
[DEBUG] [elf] Dynamic tag 16 not handled
DEBUG: Dynamic tag 16 not handled
Cannot determine entrypoint, using 0x00000d28.
EOF
RUN

View File

@ -25,7 +25,7 @@ EXPECT=<<EOF
EOF
EXPECT_ERR=<<EOF
Warning: run r2 with -e bin.cache=true to fix relocations in disassembly
ERROR: Cannot write in here, check map permissions or reopen the file with oo+
ERROR: Cannot write. Check `omp` or reopen the file with `oo+`
EOF
RUN
@ -44,6 +44,6 @@ hello
EOF
EXPECT_ERR=<<EOF
Warning: run r2 with -e bin.cache=true to fix relocations in disassembly
ERROR: Cannot write in here, check map permissions or reopen the file with oo+
ERROR: Cannot write. Check `omp` or reopen the file with `oo+`
EOF
RUN