Skip to content

Commit

Permalink
declare service_name as TCHAR array
Browse files Browse the repository at this point in the history
const qualifier loses in WinPmem constructor.
Given its access qualifier, this could be dangerous.

Array size 256 is documented to be so, Win32 API headers did not define a macro for it.
  • Loading branch information
scuzqy committed Nov 21, 2024
1 parent 3b9647f commit 1990667
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/winpmem/winpmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ int WinPmem::toggle_write_mode() {
WinPmem::WinPmem():
suppress_output(FALSE),
fd_(INVALID_HANDLE_VALUE),
out_fd_(INVALID_HANDLE_VALUE),
service_name(PMEM_SERVICE_NAME) {
out_fd_(INVALID_HANDLE_VALUE) {
_tcscpy_s(service_name, PMEM_SERVICE_NAME);
_tcscpy_s(last_error, TEXT(""));
max_physical_memory_ = 0;
}
Expand Down
4 changes: 3 additions & 1 deletion src/winpmem/winpmem.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ class WinPmem {

// The file handle to the image file.
HANDLE out_fd_;
TCHAR *service_name;

// 256: The maximum length of Windows service name string.
TCHAR service_name[256];
TCHAR driver_filename[MAX_PATH];

// This is the maximum size of memory calculated.
Expand Down

0 comments on commit 1990667

Please sign in to comment.