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-05-10 13:41:06 +0100
commit74aac7e91f90770fc18a480bd881b92127ff2b50 (patch)
tree4b76c28e3e3cef8ce1795729292f4af8bc09ea6a
parent383fc3deeca45d17010d57b119cb02969950efb5 (diff)
downloadqemu-74aac7e91f90770fc18a480bd881b92127ff2b50.tar.gz
qemu-74aac7e91f90770fc18a480bd881b92127ff2b50.tar.bz2
qemu-74aac7e91f90770fc18a480bd881b92127ff2b50.zip
binfmt: translate symbolic file links before checking /emul
Change-Id: Iba6965e166978849e6a00fe38088fdc44aad5e96 Signed-off-by: Julien Isorce <j.isorce@samsung.com>
-rw-r--r--linux-user/binfmt.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/linux-user/binfmt.c b/linux-user/binfmt.c
index 2a9009621..d8209281e 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,22 @@ 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;
+
+ path = argv[1];
+
+ /* Follow symbolic link if any. */
+ len = readlink(path, buf, sizeof(buf) - 1);
+ if (len > 0) {
+ buf[len] = 0;
+ path = buf;
+ }
- 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