Bug 1230759: Part 11 - reapplied patches from bug 1255655 draft
authorNils Ohlmeier [:drno] <drno@ohlmeier.org>
Sat, 11 Nov 2017 01:47:01 -0800
changeset 697520 7497e304a4f960891cf54d4cb5ed4e68501e9f55
parent 697519 3387a9ae7d40faea9ac8b3ee159936b1b5b1e697
child 740145 a430f2eed271d10566a74f190a28e18b11f822d1
push id89030
push userdrno@ohlmeier.org
push dateTue, 14 Nov 2017 06:38:04 +0000
bugs1230759, 1255655
milestone58.0a1
Bug 1230759: Part 11 - 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 */