only pull entropy from glibc pointer guard if glibc is actually there

This commit is contained in:
tg 2012-03-31 17:08:52 +00:00
parent 4e8c5c078d
commit b82db8764c

6
main.c
View File

@ -34,7 +34,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.212 2012/03/27 22:36:52 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.213 2012/03/31 17:08:52 tg Exp $");
extern char **environ; extern char **environ;
@ -109,7 +109,9 @@ rndsetup(void)
struct { struct {
ALLOC_ITEM alloc_INT; ALLOC_ITEM alloc_INT;
void *dataptr, *stkptr, *mallocptr; void *dataptr, *stkptr, *mallocptr;
#if defined(__GLIBC__) && (__GLIBC__ >= 2)
sigjmp_buf jbuf; sigjmp_buf jbuf;
#endif
struct timeval tv; struct timeval tv;
} *bufptr; } *bufptr;
char *cp; char *cp;
@ -127,8 +129,10 @@ rndsetup(void)
bufptr->stkptr = &bufptr; bufptr->stkptr = &bufptr;
/* randomised malloc in BSD (and possibly others) */ /* randomised malloc in BSD (and possibly others) */
bufptr->mallocptr = bufptr; bufptr->mallocptr = bufptr;
#if defined(__GLIBC__) && (__GLIBC__ >= 2)
/* glibc pointer guard */ /* glibc pointer guard */
sigsetjmp(bufptr->jbuf, 1); sigsetjmp(bufptr->jbuf, 1);
#endif
/* introduce variation (and yes, second arg MBZ for portability) */ /* introduce variation (and yes, second arg MBZ for portability) */
gettimeofday(&bufptr->tv, NULL); gettimeofday(&bufptr->tv, NULL);