9999999-NSSgetentropy.patch 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # HG changeset patch
  2. # User Bill Gianopoulos <wgianopoulos@gmail.com>
  3. # Date 1570452567 14400
  4. # Mon Oct 07 08:49:27 2019 -0400
  5. # Node ID 45bcb7edc9c43f687eb73116b2023cf793737228
  6. # Parent 4115dc9fa49df80570a5cd7c352c8c8bbf3e82b1
  7. Bug 9999999 - Avoid use of getentropy in --enable-stdcxx-compat builds.
  8. diff --git a/security/moz.build b/security/moz.build
  9. --- a/security/moz.build
  10. +++ b/security/moz.build
  11. @@ -163,16 +163,18 @@ if CONFIG["OS_TARGET"] == "WINNT":
  12. if CONFIG["OS_TARGET"] == "Android":
  13. sandbox_vars["CFLAGS"] = [
  14. "-include",
  15. TOPSRCDIR + "/security/manager/android_stub.h",
  16. ]
  17. if CONFIG["ANDROID_VERSION"]:
  18. sandbox_vars["CFLAGS"] += ["-DANDROID_VERSION=" + CONFIG["ANDROID_VERSION"]]
  19. +if CONFIG["MOZ_LIBSTDCXX_TARGET_VERSION"] or CONFIG["MOZ_LIBSTDCXX_HOST_VERSION"]:
  20. + sandbox_vars['CFLAGS'] = ['-DNSS_STDCXX_COMPAT']
  21. if CONFIG["MOZ_SYSTEM_NSS"]:
  22. sandbox_vars["CXXFLAGS"] = CONFIG["NSS_CFLAGS"]
  23. GYP_DIRS["nss"].sandbox_vars = sandbox_vars
  24. GYP_DIRS["nss"].no_chromium = True
  25. GYP_DIRS["nss"].no_unified = True
  26. # This maps action names from gyp files to
  27. # Python scripts that can be used in moz.build GENERATED_FILES.
  28. GYP_DIRS["nss"].action_overrides = {
  29. diff --git a/security/nss/lib/freebl/unix_urandom.c b/security/nss/lib/freebl/unix_urandom.c
  30. --- a/security/nss/lib/freebl/unix_urandom.c
  31. +++ b/security/nss/lib/freebl/unix_urandom.c
  32. @@ -28,17 +28,21 @@ RNG_SystemInfoForRNG(void)
  33. size_t
  34. RNG_SystemRNG(void *dest, size_t maxLen)
  35. {
  36. int fd;
  37. int bytes;
  38. size_t fileBytes = 0;
  39. unsigned char *buffer = dest;
  40. -#if defined(__OpenBSD__) || (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || (defined(LINUX) && defined(__GLIBC__) && ((__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 25))))
  41. +#if !defined(NSS_STDCXX_COMPAT) && (defined(__OpenBSD__) || \
  42. + (defined(__FreeBSD__) && __FreeBSD_version >= 1200000) || \
  43. + (defined(LINUX) && defined(__GLIBC__) && ((__GLIBC__ > 2) || \
  44. + ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 25)))))
  45. +
  46. int result;
  47. while (fileBytes < maxLen) {
  48. size_t getBytes = maxLen - fileBytes;
  49. if (getBytes > GETENTROPY_MAX_BYTES) {
  50. getBytes = GETENTROPY_MAX_BYTES;
  51. }
  52. result = getentropy(buffer, getBytes);