author | Stephen Pohl <spohl.mozilla.bugs@gmail.com> |
Thu, 07 Mar 2013 13:41:37 -0800 | |
changeset 124155 | c8db16b1021255f063e74e91059623a35bf566d3 |
parent 124154 | 6428e127d414112ab91ee531a90ed21aefbcce53 |
child 124156 | 1d028bd354d0f3855472b78a6f97aaee94411628 |
push id | 24408 |
push user | ryanvm@gmail.com |
push date | Fri, 08 Mar 2013 04:58:11 +0000 |
treeherder | mozilla-central@cb432984d5ce [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bbondy |
bugs | 848417 |
milestone | 22.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
|
toolkit/components/maintenanceservice/workmonitor.cpp | file | annotate | diff | comparison | revisions |
--- a/toolkit/components/maintenanceservice/workmonitor.cpp +++ b/toolkit/components/maintenanceservice/workmonitor.cpp @@ -42,18 +42,18 @@ BOOL PathGetSiblingFilePath(LPWSTR desti * @param isApplying Out parameter for specifying if the status * is set to applying or not. * @return TRUE if the information was filled. */ static BOOL IsStatusApplying(LPCWSTR updateDirPath, BOOL &isApplying) { isApplying = FALSE; - WCHAR updateStatusFilePath[MAX_PATH + 1]; - wcscpy(updateStatusFilePath, updateDirPath); + WCHAR updateStatusFilePath[MAX_PATH + 1] = {L'\0'}; + wcsncpy(updateStatusFilePath, updateDirPath, MAX_PATH); if (!PathAppendSafe(updateStatusFilePath, L"update.status")) { LOG_WARN(("Could not append path for update.status file")); return FALSE; } nsAutoHandle statusFile(CreateFileW(updateStatusFilePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | @@ -97,22 +97,22 @@ IsUpdateBeingStaged(int argc, LPWSTR *ar /** * Gets the installation directory from the arguments passed to updater.exe. * * @param argcTmp The argc value normally sent to updater.exe * @param argvTmp The argv value normally sent to updater.exe * @param aResultDir Buffer to hold the installation directory. */ static BOOL -GetInstallationDir(int argcTmp, LPWSTR *argvTmp, WCHAR aResultDir[MAX_PATH]) +GetInstallationDir(int argcTmp, LPWSTR *argvTmp, WCHAR aResultDir[MAX_PATH + 1]) { if (argcTmp < 2) { return FALSE; } - wcscpy(aResultDir, argvTmp[2]); + wcsncpy(aResultDir, argvTmp[2], MAX_PATH); WCHAR* backSlash = wcsrchr(aResultDir, L'\\'); // Make sure that the path does not include trailing backslashes if (backSlash && (backSlash[1] == L'\0')) { *backSlash = L'\0'; } bool backgroundUpdate = IsUpdateBeingStaged(argcTmp, argvTmp); bool replaceRequest = (argcTmp >= 4 && wcsstr(argvTmp[3], L"/replace")); if (backgroundUpdate || replaceRequest) { @@ -299,17 +299,17 @@ ProcessSoftwareUpdateCommand(DWORD argc, !WriteStatusFailure(argv[1], SERVICE_NOT_ENOUGH_COMMAND_LINE_ARGS)) { LOG_WARN(("Could not write update.status service update failure. (%d)", GetLastError())); } return FALSE; } - WCHAR installDir[MAX_PATH] = {L'\0'}; + WCHAR installDir[MAX_PATH + 1] = {L'\0'}; if (!GetInstallationDir(argc, argv, installDir)) { LOG_WARN(("Could not get the installation directory")); if (!WriteStatusFailure(argv[1], SERVICE_INSTALLDIR_ERROR)) { LOG_WARN(("Could not write update.status for GetInstallationDir failure.")); } return FALSE; }