diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-05-27 22:09:40 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-05-27 22:09:40 +0000 |
commit | c6059e6980a295388c583748215e135a5d1494e5 (patch) | |
tree | a12778eda14550d9b6481a53aec51efde3c7a7d0 /libc/sysdeps/linux | |
parent | 97f7b347cf7cd3f4d72523e1df99334ce9ed9e42 (diff) |
touchup defines so that we can use same ssp.c in both glibc and uclibc
Diffstat (limited to 'libc/sysdeps/linux')
-rw-r--r-- | libc/sysdeps/linux/common/ssp.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/libc/sysdeps/linux/common/ssp.c b/libc/sysdeps/linux/common/ssp.c index 9db8338e7..01b934b4a 100644 --- a/libc/sysdeps/linux/common/ssp.c +++ b/libc/sysdeps/linux/common/ssp.c @@ -21,7 +21,7 @@ #endif #ifdef __SSP__ -#error ssp.c has to be built w/ -fno-stack-protector +# error ssp.c has to be built w/ -fno-stack-protector #endif #include <stdio.h> @@ -45,13 +45,23 @@ # define SSP_SIGTYPE SIGABRT #endif -/* prototypes */ -extern int __libc_open (__const char *file, int oflag, ...); -extern ssize_t __libc_read(int fd, void *buf, size_t count); -extern int __libc_close (int fd); - unsigned long __guard = 0UL; +/* Use of __* functions from the rest of glibc here avoids + * initialisation problems for executables preloaded with + * libraries that overload the associated standard library + * functions. + */ +#ifdef __UCLIBC__ +extern int __libc_open(__const char *file, int flags, ...); +extern ssize_t __libc_read(int fd, void *buf, size_t count); +extern int __libc_close(int fd); +#else +# define __libc_open(file, flags) __open(file, flags) +# define __libc_read(fd, buf, count) __read(fd, buf, count) +# define __libc_close(fd) __close(fd) +#endif + void __guard_setup(void) __attribute__ ((constructor)); void __guard_setup(void) { @@ -66,16 +76,18 @@ void __guard_setup(void) #ifndef __SSP_QUICK_CANARY__ # ifdef __SSP_USE_ERANDOM__ - int mib[3]; - /* Random is another depth in Linux, hence an array of 3. */ - mib[0] = CTL_KERN; - mib[1] = KERN_RANDOM; - mib[2] = RANDOM_ERANDOM; - - size = sizeof(unsigned long); - if (__sysctl(mib, 3, &__guard, &size, NULL, 0) != (-1)) - if (__guard != 0UL) - return; + { + int mib[3]; + /* Random is another depth in Linux, hence an array of 3. */ + mib[0] = CTL_KERN; + mib[1] = KERN_RANDOM; + mib[2] = RANDOM_ERANDOM; + + size = sizeof(unsigned long); + if (__sysctl(mib, 3, &__guard, &size, NULL, 0) != (-1)) + if (__guard != 0UL) + return; + } # endif /* ifdef __SSP_USE_ERANDOM__ */ /* * Attempt to open kernel pseudo random device if one exists before |