Bug 1487126 Change uses of 3-argument wcstok to wcstok_s r=mhowell
authorTom Ritter <tom@mozilla.com>
Wed, 29 Aug 2018 16:29:47 +0000
changeset 491691 59227967b5b5ecfaede4ca73fe26c5764672ca19
parent 491690 68480edad09616504254f0e2d4ca663dfda20183
child 491692 1eb9734029b1766f653238a8ee94c6e88d4bd3f6
push id1815
push userffxbld-merge
push dateMon, 15 Oct 2018 10:40:45 +0000
treeherdermozilla-release@18d4c09e9378 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmhowell
bugs1487126
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1487126 Change uses of 3-argument wcstok to wcstok_s r=mhowell the Mingw Clang build failed because a 3-argument form of wcstok could not be found, despite it apparently being part of the C++ standard. Multiple forms of header files were tried. By comparison, wcstok_s is already used (e.g. widget/windows/WinUtils.cpp) and does the correct thing. So change the functions over to that one. Differential Revision: https://phabricator.services.mozilla.com/D4568
toolkit/mozapps/update/common/updatecommon.cpp
--- a/toolkit/mozapps/update/common/updatecommon.cpp
+++ b/toolkit/mozapps/update/common/updatecommon.cpp
@@ -194,17 +194,17 @@ void UpdateLog::WarnPrintf(const char *f
  *         false if the check passes and the path can be used
  */
 bool
 PathContainsInvalidLinks(wchar_t * const fullPath)
 {
   wchar_t pathCopy[MAXPATHLEN + 1] = L"";
   wcsncpy(pathCopy, fullPath, MAXPATHLEN);
   wchar_t* remainingPath = nullptr;
-  wchar_t* nextToken = wcstok(pathCopy, L"\\", &remainingPath);
+  wchar_t* nextToken = wcstok_s(pathCopy, L"\\", &remainingPath);
   wchar_t* partialPath = nextToken;
 
   while (nextToken) {
     if ((GetFileAttributesW(partialPath) & FILE_ATTRIBUTE_REPARSE_POINT) != 0) {
       nsAutoHandle h(CreateFileW(partialPath, 0,
                                  FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
                                  nullptr, OPEN_EXISTING,
                                  FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT,
@@ -244,17 +244,17 @@ PathContainsInvalidLinks(wchar_t * const
           break;
       }
 
       if (wcsncmp(reparseTarget, L"\\??\\", ARRAYSIZE(L"\\??\\") - 1) != 0) {
         return true;
       }
     }
 
-    nextToken = wcstok(nullptr, L"\\", &remainingPath);
+    nextToken = wcstok_s(nullptr, L"\\", &remainingPath);
     PathAppendW(partialPath, nextToken);
   }
 
   return false;
 }
 #endif
 
 /**