Skip to content

Commit

Permalink
Fix #1007: strcpy requires the number of chars not bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
xupefei committed Oct 18, 2021
1 parent fe6dae6 commit e640a8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion QuickLook.Native/QuickLook.Native32/DOpus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void DOpus::ParseXmlBuffer(PWCHAR buffer)
auto b = new WCHAR[size];
MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, path, -1, b, size);

wcscpy_s(buffer, MAX_PATH_EX, b); // DOpus supports Long Path
wcscpy_s(buffer, wcslen(b) + 1, b); // DOpus supports Long Path

delete[] b;
return; // we now cares only the first result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ void GetCurrentSelection()
if (hMapFile == nullptr)
return;

auto buffer = static_cast<PWCHAR>(MapViewOfFile(hMapFile, FILE_MAP_ALL_ACCESS, 0, 0, MAX_PATH * sizeof WCHAR));
auto buffer = static_cast<PWCHAR>(MapViewOfFile(hMapFile, FILE_MAP_WRITE, 0, 0, 0));
if (buffer == nullptr)
{
CloseHandle(hMapFile);
return;
}

wcscpy_s(buffer, MAX_PATH_EX, dllBuffer);
wcscpy_s(buffer, wcslen(dllBuffer) + 1, dllBuffer);

UnmapViewOfFile(buffer);
CloseHandle(hMapFile);
Expand Down

0 comments on commit e640a8b

Please sign in to comment.