summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Isorce <j.isorce@samsung.com>2016-05-10 13:18:06 +0100
committerJulien Isorce <j.isorce@samsung.com>2016-08-22 11:28:29 +0100
commit7400d2f00938b655cc7373343d53e20d29b9776b (patch)
treed79e8c75090dee7b68e580b44229a57a51082e56
parent273e681f8f5c851b8b52ddc6d86002e079c6f2da (diff)
downloadqemu-7400d2f00938b655cc7373343d53e20d29b9776b.tar.gz
qemu-7400d2f00938b655cc7373343d53e20d29b9776b.tar.bz2
qemu-7400d2f00938b655cc7373343d53e20d29b9776b.zip
binfmt: translate symbolic links correctly with realpathsubmit/tizen_base/20160909.055201
Change-Id: Ic0eeac9de40a8e1082c83b442829ac28f68bff04 Signed-off-by: Julien Isorce <j.isorce@samsung.com> Signed-off-by: Yury Usishchev <y.usishchev@samsung.com>
-rw-r--r--linux-user/binfmt.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/linux-user/binfmt.c b/linux-user/binfmt.c
index 2a9009621..e9e9b6583 100644
--- a/linux-user/binfmt.c
+++ b/linux-user/binfmt.c
@@ -4,6 +4,7 @@
#include <libgen.h>
#include <string.h>
#include <stdlib.h>
+#include <limits.h>
int main(int argc, char **argv, char **envp)
@@ -29,10 +30,20 @@ int main(int argc, char **argv, char **envp)
/* Now argv[0] is the real qemu binary name */
{
- char *hostbin;
+ int len;
int r;
+ char buf[PATH_MAX];
+ char *hostbin;
+ char *path;
+
+ /* Follow symbolic link if any. */
+ path = realpath(argv[1], buf);
+ if (path == NULL) {
+ /* Error occured, falling back to original argument */
+ path = argv[1];
+ }
- r = asprintf(&hostbin, "/emul/%s", argv[1]);
+ r = asprintf(&hostbin, "/emul/%s", path);
if (!access(hostbin, X_OK) && (r > 0)) {
/*
* We found a host binary replacement for the non-host binary. Let's