Bug 1230759: Part 12 - reapplied patches from bug 1255655 draft
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Sat, 11 Nov 2017 01:47:01 -0800
changeset 696869 18ab83496e632d55835fdad55f75949b17b5b5b6
parent 696868 eb110b6385a5f6df7a4aeaf8cda4e0047ca7f92b
child 739947 2c7e0ba48124991efa358f0a6ae09b5cf2ae129c
push id88810
push userdrno@ohlmeier.org
push dateSun, 12 Nov 2017 02:22:41 +0000
bugs1230759, 1255655
milestone58.0a1
Bug 1230759: Part 12 - reapplied patches from bug 1255655 MozReview-Commit-ID: 6pPJIopaMlA
netwerk/srtp/src/crypto/math/datatypes.c
--- a/netwerk/srtp/src/crypto/math/datatypes.c
+++ b/netwerk/srtp/src/crypto/math/datatypes.c
@@ -48,35 +48,40 @@
 #endif
 
 #ifdef OPENSSL
 #include <openssl/crypto.h>
 #endif
 
 #include "datatypes.h"
 
-int octet_weight[256] = {
+// MOZILLA: upstream code lacks |static const| and uses |int| elements, which
+// means it isn't read-only and so cannot be shared between processes, and is
+// four times bigger than necessary. Please preserve these changes until they
+// are upstreamed.
+static const int8_t
+octet_weight[256] = {
     0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4,
     2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
     2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4,
     2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
     2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
     4, 5, 5, 6, 5, 6, 6, 7, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
     2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5,
     3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
     2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6,
     4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
     4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
 };
 
 int octet_get_weight(uint8_t octet)
 {
-    extern int octet_weight[256];
-
-    return octet_weight[octet];
+  // MOZILLA: upstream code here is slightly different due to the changes we've
+  // made to octet_weight's declaration above
+  return (int)octet_weight[octet];
 }
 
 /*
  * bit_string is a buffer that is used to hold output strings, e.g.
  * for printing.
  */
 
 /* the value MAX_PRINT_STRING_LEN is defined in datatypes.h */