suhosin-ext_suhosin_execute_c 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. $OpenBSD: suhosin-ext_suhosin_execute_c,v 1.1 2016/06/22 21:18:33 sthen Exp $
  2. --- ext/suhosin/execute.c.orig.port Mon Feb 1 23:04:02 2016
  3. +++ ext/suhosin/execute.c Mon Feb 1 23:38:49 2016
  4. @@ -1312,6 +1312,9 @@ static php_uint32 suhosin_mt_rand(TSRMLS_D)
  5. */
  6. static void suhosin_gen_entropy(php_uint32 *entropybuf TSRMLS_DC)
  7. {
  8. +#if defined(__OpenBSD__)
  9. + arc4random_buf(entropybuf, 8 * sizeof(php_uint32));
  10. +#else
  11. php_uint32 seedbuf[20];
  12. /* On a modern OS code, stack and heap base are randomized */
  13. unsigned long code_value = (unsigned long)suhosin_gen_entropy;
  14. @@ -1335,7 +1338,7 @@ static void suhosin_gen_entropy(php_uint32 *entropybuf
  15. #endif
  16. seedbuf[5] = (php_uint32) 0x7fffffff * php_combined_lcg(TSRMLS_C);
  17. -#ifndef PHP_WIN32
  18. +#if !defined(PHP_WIN32)
  19. fd = VCWD_OPEN("/dev/urandom", O_RDONLY);
  20. if (fd >= 0) {
  21. /* ignore error case - if urandom doesn't give us any/enough random bytes */
  22. @@ -1354,6 +1357,7 @@ static void suhosin_gen_entropy(php_uint32 *entropybuf
  23. suhosin_SHA256Update(&context, (unsigned char*)SUHOSIN_G(seedingkey), strlen(SUHOSIN_G(seedingkey)));
  24. }
  25. suhosin_SHA256Final((void *)entropybuf, &context);
  26. +#endif /* openbsd */
  27. }
  28. /* }}} */