--- libssp/ssp.c.orig 2005-11-05 21:11:19.000000000 +0000 +++ libssp/ssp.c 2005-11-05 21:41:47.000000000 +0000 @@ -58,6 +58,15 @@ void *__stack_chk_guard = 0; +#define __libc_open(file, flags) __open(file, flags) +#define __libc_read(fd, buf, count) __read(fd, buf, count) +#define __libc_close(fd) __close(fd) +#define __libc_write(fd, buf, count) __write(fd, buf, count) + +#ifdef __SSP__ +# error ssp.c has to be built w/ -fno-stack-protector +#endif + static void __attribute__ ((constructor)) __guard_setup (void) { @@ -67,12 +76,12 @@ if (__stack_chk_guard != 0) return; - fd = open ("/dev/urandom", O_RDONLY); + fd = __libc_open("/dev/urandom", O_RDONLY); if (fd != -1) { - ssize_t size = read (fd, &__stack_chk_guard, + ssize_t size = _libc_read(fd, &__stack_chk_guard, sizeof (__stack_chk_guard)); - close (fd); + __libc_close(fd); if (size == sizeof(__stack_chk_guard) && __stack_chk_guard != 0) return; } @@ -97,7 +106,7 @@ /* Print error message directly to the tty. This avoids Bad Things happening if stderr is redirected. */ - fd = open (_PATH_TTY, O_WRONLY); + fd = __libc_open(_PATH_TTY, O_WRONLY); if (fd != -1) { static const char msg2[] = " terminated\n"; @@ -122,7 +131,7 @@ buf += wrote; len -= wrote; } - close (fd); + __libc_close(fd); } #ifdef HAVE_SYSLOG_H