From libressl Thu Jul 21 09:25:08 2016 From: schily () schily ! net (Joerg Schilling) Date: Thu, 21 Jul 2016 09:25:08 +0000 To: libressl Subject: Non-portable code in ./crypto/compat/getentropy_solaris.c Message-Id: <579094f4.Ca9M384ri4oiBOIa%schily () schily ! net> X-MARC-Message: https://marc.info/?l=libressl&m=146910737815443 Hi, the code works only on Solaris based on OpenSolaris-ON from February 18 2010 or later. Many people however still use Solaris 10. BTW: there is an official portable ELF way based on the AUX vector to do the same but this was unfortunately not made a public libc interface, so it would need to be incorporated into your code: https://sourceforge.net/p/schillix-on/schillix-on/ci/default/tree/usr/src/lib/libc/port/gen/getauxv.c ___getauxptr(AT_PHDR) returns the address of &phdr[0] ___getauxval(AT_PHENT) returns sizeof(phdr[0]) ___getauxval(AT_PHNUM) returns # phdr entries Here is a patch to disable the non-portable code getting the code to compile at all: --- a/crypto/compat/getentropy_solaris.c +++ b/crypto/compat/getentropy_solaris.c @@ -72,7 +72,9 @@ static int getentropy_urandom(void *buf, size_t len, const char *path, int devfscheck); static int getentropy_fallback(void *buf, size_t len); +#ifdef ElfW static int getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data); +#endif int getentropy(void *buf, size_t len) @@ -244,6 +246,7 @@ #endif }; +#ifdef ElfW static int getentropy_phdr(struct dl_phdr_info *info, size_t size, void *data) { @@ -252,6 +255,7 @@ SHA512_Update(ctx, &info->dlpi_addr, sizeof (info->dlpi_addr)); return (0); } +#endif static int getentropy_fallback(void *buf, size_t len) @@ -290,7 +294,9 @@ cnt += (int)tv.tv_usec; } +#ifdef ElfW dl_iterate_phdr(getentropy_phdr, &ctx); +#endif for (ii = 0; ii < sizeof(cl)/sizeof(cl[0]); ii++) HX(clock_gettime(cl[ii], &ts) == -1, ts);