Bug 1199624 - Don't use memset and memcmp in files that don't include cstring explicitly. r=briansmith
authorJacek Caban <jacek@codeweavers.com>
Wed, 09 Sep 2015 14:16:59 +0200
changeset 261576 a3197d3b445b7e6cd005d908e4f581308d84428a
parent 261575 5bb965937e246fe7d6017bba825902931727b095
child 261577 41005726fcc1dcf1f47f07f1c8830a6c45b8c0f7
push id15105
push userkwierso@gmail.com
push dateWed, 09 Sep 2015 20:53:22 +0000
treeherderfx-team@dd2a1d737a64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbriansmith
bugs1199624
milestone43.0a1
Bug 1199624 - Don't use memset and memcmp in files that don't include cstring explicitly. r=briansmith
security/pkix/lib/pkixcheck.cpp
security/pkix/lib/pkixnames.cpp
--- a/security/pkix/lib/pkixcheck.cpp
+++ b/security/pkix/lib/pkixcheck.cpp
@@ -482,18 +482,17 @@ static const uint8_t anyPolicy[] = {
 };
 
 bool
 CertPolicyId::IsAnyPolicy() const {
   if (this == &CertPolicyId::anyPolicy) {
     return true;
   }
   return numBytes == sizeof(::mozilla::pkix::anyPolicy) &&
-         !memcmp(bytes, ::mozilla::pkix::anyPolicy,
-                 sizeof(::mozilla::pkix::anyPolicy));
+         std::equal(bytes, bytes + numBytes, ::mozilla::pkix::anyPolicy);
 }
 
 // certificatePolicies ::= SEQUENCE SIZE (1..MAX) OF PolicyInformation
 Result
 CheckCertificatePolicies(EndEntityOrCA endEntityOrCA,
                          const Input* encodedCertificatePolicies,
                          const Input* encodedInhibitAnyPolicy,
                          TrustLevel trustLevel,
--- a/security/pkix/lib/pkixnames.cpp
+++ b/security/pkix/lib/pkixnames.cpp
@@ -1695,18 +1695,18 @@ FinishIPv6Address(/*in/out*/ uint8_t (&a
 
   // Shift components that occur after the contraction over.
   size_t componentsToMove = static_cast<size_t>(numComponents -
                                                 contractionIndex);
   memmove(address + (2u * static_cast<size_t>(8 - componentsToMove)),
           address + (2u * static_cast<size_t>(contractionIndex)),
           componentsToMove * 2u);
   // Fill in the contracted area with zeros.
-  memset(address + (2u * static_cast<size_t>(contractionIndex)), 0u,
-         (8u - static_cast<size_t>(numComponents)) * 2u);
+  std::fill_n(address + 2u * static_cast<size_t>(contractionIndex),
+              (8u - static_cast<size_t>(numComponents)) * 2u, static_cast<uint8_t>(0u));
 
   return true;
 }
 
 } // unnamed namespace
 
 // On Windows and maybe other platforms, OS-provided IP address parsing
 // functions might fail if the protocol (IPv4 or IPv6) has been disabled, so we