summaryrefslogtreecommitdiff
path: root/loader
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2018-02-07 20:21:57 -0600
committerWilliam Pitcock <nenolod@dereferenced.org>2018-02-07 20:21:57 -0600
commit2a542af8829c4fa938556dbf404fcf21fefbf91d (patch)
tree7a6580e0034fc294026a07235df53cfa0abaa877 /loader
parenta855c926fe865911611a82eedaebaf0f780f2bbd (diff)
downloadgcompat-2a542af8829c4fa938556dbf404fcf21fefbf91d.tar.gz
gcompat-2a542af8829c4fa938556dbf404fcf21fefbf91d.tar.bz2
gcompat-2a542af8829c4fa938556dbf404fcf21fefbf91d.tar.xz
gcompat-2a542af8829c4fa938556dbf404fcf21fefbf91d.zip
loader: gracefully handle user-exec of the ELF interpreter itself
Diffstat (limited to 'loader')
-rw-r--r--loader/loader.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/loader/loader.c b/loader/loader.c
index 53a2c38..ebcdbfe 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -34,6 +34,12 @@
#error LOADER must be defined
#endif
+void usage(void)
+{
+ printf("This is the gcompat ELF interpreter stub.\n");
+ printf("You are not meant to run this directly.\n");
+}
+
/*
* Given the argv { "foo", "bar", "baz" }, and the environment variable
* "LD_PRELOAD=/another/preload.so", the new argv will be {
@@ -96,6 +102,12 @@ int main(int argc, char *argv[], char *envp[])
}
target[len] = '\0';
+ /* somebody is trying to run the loader directly */
+ if (strstr(target, LOADER) != NULL) {
+ usage();
+ return EXIT_FAILURE;
+ }
+
new_argv[0] = LOADER;
new_argv[1] = "--argv0";
new_argv[2] = argv[0];