From f37310ef1926b163787e24d5e4d20da596c5b3f3 Mon Sep 17 00:00:00 2001 From: "John Hodge (sonata)" Date: Fri, 7 Nov 2014 11:42:10 +0800 Subject: [PATCH] AcessNative - Remove errnous function defintions that caused global constructors to not run --- AcessNative/libacess-native.so_src/main.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/AcessNative/libacess-native.so_src/main.c b/AcessNative/libacess-native.so_src/main.c index d1e86847..b5f066f7 100644 --- a/AcessNative/libacess-native.so_src/main.c +++ b/AcessNative/libacess-native.so_src/main.c @@ -48,6 +48,7 @@ int libacessnative_init(int argc, char *argv[], char **envp) printf("preopens = %s\n", preopens); if( preopens ) { + int exp_fd = 0; while( *preopens ) { const char *splitter = strchr(preopens, ':'); @@ -64,7 +65,15 @@ int libacessnative_init(int argc, char *argv[], char **envp) int fd = acess__SysOpen(path, 6); // WRITE,READ,no EXEC if( fd == -1 ) { fprintf(stderr, "Unable to preopen '%s' errno=%i\n", path, acess__errno); + exit(1); } + if( fd != exp_fd ) { + // Oh... this is bad + fprintf(stderr, "Pre-opening '%s' resulted in an incorrect FD (expected %i, got %i)", + path, exp_fd, fd); + exit(1); + } + exp_fd += 1; if( !splitter ) break; @@ -131,17 +140,3 @@ void Warning(const char *format, ...) printf("\n"); } -void __libc_csu_fini() -{ -} - -void __libc_csu_init() -{ -} - -void __stack_chk_fail(void) -{ - fprintf(stderr, "__stack_chk_fail"); - exit(1); -} - -- 2.20.1