Bug 1308100 - Replace PL_strlen/PL_strnlen with strlen/strnlen;r?erahm draft
authorAdam Velebil <adamtomasv@gmail.com>
Thu, 13 Apr 2017 20:47:00 +0200
changeset 562251 8ea217828095c5a08100769ff81eb4a8b6cbb784
parent 559749 b1364675bdf5dffe63fd60373034293de0b513d5
child 624218 3efa66e7d923e25c3738d5b84a7f382a1e1be85a
push id54003
push useradamtomasv@gmail.com
push dateThu, 13 Apr 2017 18:55:33 +0000
reviewerserahm
bugs1308100
milestone55.0a1
Bug 1308100 - Replace PL_strlen/PL_strnlen with strlen/strnlen;r?erahm MozReview-Commit-ID: CGnzomkIsi5 *** Bug 1308100 - Replace PL_strlen/PL_strnlen with strlen/strnlen;r?erahm
media/webrtc/signaling/src/sdp/sipcc/sdp_attr.c
netwerk/cache2/CacheHashUtils.cpp
netwerk/wifi/nsWifiScannerSolaris.cpp
security/certverifier/OCSPRequestor.cpp
--- a/media/webrtc/signaling/src/sdp/sipcc/sdp_attr.c
+++ b/media/webrtc/signaling/src/sdp/sipcc/sdp_attr.c
@@ -453,17 +453,17 @@ static void sdp_attr_fmtp_invalid_value(
 }
 
 /*
  * sdp_verify_attr_fmtp_telephone_event
  * Helper function for verifying the telephone-event fmtp format
  */
 static sdp_result_e sdp_verify_attr_fmtp_telephone_event(char *fmtpVal)
 {
-  size_t len = PL_strlen(fmtpVal);
+  size_t len = fmtpVal ? strlen(fmtpVal) : 0;
 
   // make sure the basics are good:
   // - at least 1 character
   // - no illegal chars
   // - first char is a number
   if (len < 1
       || strspn(fmtpVal, "0123456789,-") != len
       || PL_strstr(fmtpVal, ",,")
@@ -477,17 +477,17 @@ static sdp_result_e sdp_verify_attr_fmtp
   // the input string.
   char dtmf_tones[SDP_MAX_STRING_LEN+1];
   PL_strncpyz(dtmf_tones, fmtpVal, sizeof(dtmf_tones));
 
   char *strtok_state;
   char *temp = PL_strtok_r(dtmf_tones, ",", &strtok_state);
 
   while (temp != NULL) {
-    len = PL_strlen(temp);
+    len = strlen(temp);
     if (len > 5) {
       // an example of a max size token is "11-15", so if the
       // token is longer than 5 it is bad
       return SDP_INVALID_PARAMETER;
     }
 
     // case where we have 1 or 2 characters, example 4 or 23
     if (len < 3 && strspn(temp, "0123456789") != len) {
--- a/netwerk/cache2/CacheHashUtils.cpp
+++ b/netwerk/cache2/CacheHashUtils.cpp
@@ -33,17 +33,16 @@ static inline void hashmix(uint32_t& a, 
 }
 
 CacheHash::Hash32_t
 CacheHash::Hash(const char *aData, uint32_t aSize, uint32_t aInitval)
 {
   const uint8_t *k = reinterpret_cast<const uint8_t*>(aData);
   uint32_t a, b, c, len;
 
-//  length = PL_strlen(key);
   /* Set up the internal state */
   len = aSize;
   a = b = 0x9e3779b9;  /* the golden ratio; an arbitrary value */
   c = aInitval;        /* variable initialization of internal state */
 
   /*---------------------------------------- handle most of the key */
   while (len >= 12)
   {
--- a/netwerk/wifi/nsWifiScannerSolaris.cpp
+++ b/netwerk/wifi/nsWifiScannerSolaris.cpp
@@ -4,17 +4,16 @@
 
 #include "nsWifiMonitor.h"
 #include "nsWifiAccessPoint.h"
 
 #include "nsServiceManagerUtils.h"
 #include "nsComponentManagerUtils.h"
 #include "nsIMutableArray.h"
 
-#include "plstr.h"
 #include <glib.h>
 
 #define DLADM_STRSIZE 256
 #define DLADM_SECTIONS 3
 
 using namespace mozilla;
 
 struct val_strength_t {
@@ -45,17 +44,18 @@ do_parse_str(char *bssid_str, char *essi
       break;
     }
   }
 
   nsWifiAccessPoint *ap = new nsWifiAccessPoint();
   if (ap) {
     ap->setMac(mac_as_int);
     ap->setSignal(signal);
-    ap->setSSID(essid_str, PL_strnlen(essid_str, DLADM_STRSIZE));
+    size_t len = essid_str ? strnlen(essid_str, DLADM_STRSIZE) : 0;
+    ap->setSSID(essid_str, len);
   }
   return ap;
 }
 
 static void
 do_dladm(nsCOMArray<nsWifiAccessPoint> &accessPoints)
 {
   GError *err = nullptr;
--- a/security/certverifier/OCSPRequestor.cpp
+++ b/security/certverifier/OCSPRequestor.cpp
@@ -81,17 +81,17 @@ DoOCSPRequest(const UniquePLArenaPool& a
 {
   MOZ_ASSERT(arena.get());
   MOZ_ASSERT(url);
   MOZ_ASSERT(encodedRequest);
   MOZ_ASSERT(encodedRequest->data);
   if (!arena.get() || !url || !encodedRequest || !encodedRequest->data) {
     return Result::FATAL_ERROR_INVALID_ARGS;
   }
-  uint32_t urlLen = PL_strlen(url);
+  uint32_t urlLen = strlen(url);
   if (urlLen > static_cast<uint32_t>(std::numeric_limits<int32_t>::max())) {
     return Result::FATAL_ERROR_INVALID_ARGS;
   }
 
   nsCOMPtr<nsIURLParser> urlParser = do_GetService(NS_STDURLPARSER_CONTRACTID);
   if (!urlParser) {
     return Result::FATAL_ERROR_LIBRARY_FAILURE;
   }