diff options
Diffstat (limited to 'libsandbox/wrapper-funcs')
-rw-r--r-- | libsandbox/wrapper-funcs/__wrapper_simple.c | 5 | ||||
-rw-r--r-- | libsandbox/wrapper-funcs/getcwd.c | 36 |
2 files changed, 13 insertions, 28 deletions
diff --git a/libsandbox/wrapper-funcs/__wrapper_simple.c b/libsandbox/wrapper-funcs/__wrapper_simple.c index 1cdf176..de3dafd 100644 --- a/libsandbox/wrapper-funcs/__wrapper_simple.c +++ b/libsandbox/wrapper-funcs/__wrapper_simple.c @@ -26,6 +26,9 @@ #ifndef WRAPPER_SAFE_POST_EXPAND # define WRAPPER_SAFE_POST_EXPAND #endif +#ifndef WRAPPER_POST_EXPAND +# define WRAPPER_POST_EXPAND +#endif extern WRAPPER_RET_TYPE EXTERN_NAME(WRAPPER_ARGS_PROTO); static WRAPPER_RET_TYPE (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS_PROTO) = NULL; @@ -49,6 +52,7 @@ WRAPPER_RET_TYPE WRAPPER_NAME(WRAPPER_ARGS_PROTO) if (WRAPPER_SAFE()) { WRAPPER_SAFE_POST_EXPAND result = SB_HIDDEN_FUNC(WRAPPER_NAME)(WRAPPER_ARGS_FULL); + WRAPPER_POST_EXPAND } return result; @@ -57,3 +61,4 @@ WRAPPER_RET_TYPE WRAPPER_NAME(WRAPPER_ARGS_PROTO) #undef WRAPPER_ARGS_FULL #undef WRAPPER_ARGS_PROTO_FULL #undef WRAPPER_SAFE_POST_EXPAND +#undef WRAPPER_POST_EXPAND diff --git a/libsandbox/wrapper-funcs/getcwd.c b/libsandbox/wrapper-funcs/getcwd.c index aaa7ab9..851f359 100644 --- a/libsandbox/wrapper-funcs/getcwd.c +++ b/libsandbox/wrapper-funcs/getcwd.c @@ -3,37 +3,17 @@ * * Copyright 1999-2008 Gentoo Foundation * Licensed under the GPL-2 - * - * Partly Copyright (C) 1998-9 Pancrazio `Ezio' de Mauro <p@demauro.net>, - * as some of the InstallWatch code was used. */ #define WRAPPER_ARGS_PROTO char *buf, size_t size #define WRAPPER_ARGS buf, size #define WRAPPER_RET_TYPE char * #define WRAPPER_RET_DEFAULT NULL - -extern WRAPPER_RET_TYPE EXTERN_NAME(WRAPPER_ARGS_PROTO); -static WRAPPER_RET_TYPE (*WRAPPER_TRUE_NAME)(WRAPPER_ARGS_PROTO) = NULL; - -attribute_hidden -WRAPPER_RET_TYPE SB_HIDDEN_FUNC(WRAPPER_NAME)(WRAPPER_ARGS_PROTO) -{ - check_dlsym(WRAPPER_TRUE_NAME, WRAPPER_SYMNAME, WRAPPER_SYMVER); - return WRAPPER_TRUE_NAME(WRAPPER_ARGS); -} - -WRAPPER_RET_TYPE WRAPPER_NAME(WRAPPER_ARGS_PROTO) -{ - WRAPPER_RET_TYPE result = WRAPPER_RET_DEFAULT; - - /* Need to disable sandbox, as on non-linux libc's, opendir() is - * used by some getcwd() implementations and resolves to the sandbox - * opendir() wrapper, causing infinit recursion and finially crashes. - */ - sandbox_on = false; - result = SB_HIDDEN_FUNC(WRAPPER_NAME)(WRAPPER_ARGS); - sandbox_on = true; - - return result; -} +#define WRAPPER_SAFE() true +/* Need to disable sandbox, as on non-linux libc's, opendir() is often + * used by some getcwd() implementations and resolves to the sandbox + * opendir() wrapper, causing infinite recursion and finally crashes. + */ +#define WRAPPER_SAFE_POST_EXPAND sandbox_on = false; +#define WRAPPER_POST_EXPAND sandbox_on = true; +#include "__wrapper_simple.c" |