Bug 888314. r=rstrong

This commit is contained in:
Brian R. Bondy 2013-07-01 19:11:59 -04:00
parent 10e772f676
commit 5a1474f31c

View File

@ -2920,7 +2920,8 @@ int NS_main(int argc, NS_tchar **argv)
NS_tchar callbackLongPath[MAXPATHLEN];
ZeroMemory(callbackLongPath, sizeof(callbackLongPath));
NS_tchar *targetPath = argv[callbackIndex];
NS_tchar buffer[MAXPATHLEN*2];
NS_tchar buffer[MAXPATHLEN * 2] = { NS_T('\0') };
size_t bufferLeft = MAXPATHLEN * 2;
if (sReplaceRequest) {
// In case of replace requests, we should look for the callback file in
// the destination directory.
@ -2928,16 +2929,21 @@ int NS_main(int argc, NS_tchar **argv)
NS_tchar *p = buffer;
NS_tstrncpy(p, argv[callbackIndex], commonPrefixLength);
p += commonPrefixLength;
NS_tstrcpy(p, gDestinationPath + commonPrefixLength);
p += NS_tstrlen(gDestinationPath + commonPrefixLength);
bufferLeft -= commonPrefixLength;
NS_tstrncpy(p, gDestinationPath + commonPrefixLength, bufferLeft);
size_t len = NS_tstrlen(gDestinationPath + commonPrefixLength);
p += len;
bufferLeft -= len;
*p = NS_T('\\');
++p;
bufferLeft--;
*p = NS_T('\0');
NS_tchar installDir[MAXPATHLEN];
if (!GetInstallationDir(installDir))
return 1;
size_t callbackPrefixLength = PathCommonPrefixW(argv[callbackIndex], installDir, NULL);
NS_tstrcpy(p, argv[callbackIndex] + max(callbackPrefixLength, commonPrefixLength));
NS_tstrncpy(p, argv[callbackIndex] + max(callbackPrefixLength, commonPrefixLength), bufferLeft);
targetPath = buffer;
}
if (!GetLongPathNameW(targetPath, callbackLongPath,