From 7e5f1f5851ea41f615bf956c54d4f48abfcf46ad Mon Sep 17 00:00:00 2001 From: pancake Date: Mon, 17 Jun 2013 11:41:00 +0200 Subject: [PATCH] No ldconfig if /usr installs and fix segfault using RCore api --- libr/bin/bin.c | 2 +- libr/core/file.c | 2 +- r2-bindings/python/test-r_core.py | 5 ++++- sys/ldconfig.sh | 8 ++++++-- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/libr/bin/bin.c b/libr/bin/bin.c index 4a2bc054ad..08a8ce99d2 100644 --- a/libr/bin/bin.c +++ b/libr/bin/bin.c @@ -163,7 +163,7 @@ static int r_bin_init_items(RBin *bin, int dummy) { if (!cp || !cp->load || !cp->load (a)) { r_buf_free (a->buf); a->buf = r_buf_mmap (bin->cur.file, 0); - a->size = a->buf->length; + a->size = a->buf? a->buf->length: 0; o->strings = get_strings (a, minlen); return R_FALSE; } diff --git a/libr/core/file.c b/libr/core/file.c index da6d33e40a..832c528eaa 100644 --- a/libr/core/file.c +++ b/libr/core/file.c @@ -143,7 +143,7 @@ R_API int r_core_bin_load(RCore *r, const char *file) { ut64 offset; RIOMap *im; - if (file == NULL) + if (file == NULL || !*file) if (r->file) file = r->file->filename; if (!file) { diff --git a/r2-bindings/python/test-r_core.py b/r2-bindings/python/test-r_core.py index 68539fbb48..5c107115aa 100755 --- a/r2-bindings/python/test-r_core.py +++ b/r2-bindings/python/test-r_core.py @@ -14,13 +14,15 @@ core = RCore() # Detect sub-bins in fatmach0 path="/tmp/fatmach0-3true" +path="/bin/ls" core.bin.load (path, 0) print ("Supported archs: %d"%core.bin.narch) for i in range (0,core.bin.narch): core.bin.select_idx (i) info = core.bin.get_info () - print ("%d: %s %s"%(i,info.arch,info.bits)) + if info: + print ("%d: %s %s"%(i,info.arch,info.bits)) # Load file in core core.config.set ("asm.arch", "x86"); @@ -28,6 +30,7 @@ core.config.set ("asm.bits", "32"); #core.config.set ("asm.bits", "64"); f = core.file_open(path, False, 0) +#core.bin_load (None) core.bin_load ("") # show entrypoint diff --git a/sys/ldconfig.sh b/sys/ldconfig.sh index dc397c5ad7..903bc27062 100755 --- a/sys/ldconfig.sh +++ b/sys/ldconfig.sh @@ -3,8 +3,12 @@ LD=/etc/ld.so.conf.d if test -w $LD ; then if type ldconfig > /dev/null 2>&1 ; then mkdir -p $LD - awk -F= '/^LIBDIR/{print $2}' config-user.mk > $LD/radare.conf - ldconfig + P=$(awk -F= '/^LIBDIR/{print $2}' config-user.mk) + D=`dirname $P``basename $P` + if [ /usr != "$D" ]; then + echo $P > $LD/radare.conf + ldconfig + fi fi fi exit 0