Skip to content

Commit

Permalink
update HISTORY to include #1981, CREDIT @PetrPospisil, fix C linter w…
Browse files Browse the repository at this point in the history
…arnings

Signed-off-by: Giampaolo Rodola <g.rodola@gmail.com>
  • Loading branch information
giampaolo committed Oct 18, 2021
1 parent adbfeae commit d1cce5c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CREDITS
Original file line number Diff line number Diff line change
Expand Up @@ -770,3 +770,7 @@ I: 1948
N: Saeed Rasooli
W: https://github.com/ilius
I: 1996

N: PetrPospisil
W: https://github.com/PetrPospisil
I: 1980
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ XXXX-XX-XX
(patch by MaWe2019)
- 1965_: [Windows] fix "Fatal Python error: deallocating None" when calling
psutil.users() multiple times.
- 1980_: [Windows] 32bit / WOW64 processes fails to read process name longer
than 128 characters resulting in AccessDenied. This is now fixed. (patch
by PetrPospisil)
- 1991_: process_iter() can raise TypeError if invoked from multiple threads
(not thread-safe).

Expand Down
12 changes: 6 additions & 6 deletions psutil/_psutil_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,15 +366,14 @@ psutil_proc_exe(PyObject *self, PyObject *args) {
sizeof(SYSTEM_PROCESS_ID_INFORMATION),
NULL);

if (status == STATUS_INFO_LENGTH_MISMATCH && processIdInfo.ImageName.MaximumLength <= bufferSize) {
if ((status == STATUS_INFO_LENGTH_MISMATCH) &&
(processIdInfo.ImageName.MaximumLength <= bufferSize))
{
// Required length was NOT stored in MaximumLength (WOW64 issue).

ULONG maxBufferSize = 0x7FFF * 2; // NTFS_MAX_PATH * sizeof(wchar_t)

ULONG maxBufferSize = 0x7FFF * 2; // NTFS_MAX_PATH * sizeof(wchar_t)
do {
// Iteratively double the size of the buffer up to maxBufferSize
bufferSize *= 2;

FREE(buffer);
buffer = MALLOC_ZERO(bufferSize);
if (! buffer) {
Expand All @@ -390,7 +389,8 @@ psutil_proc_exe(PyObject *self, PyObject *args) {
&processIdInfo,
sizeof(SYSTEM_PROCESS_ID_INFORMATION),
NULL);
} while (status == STATUS_INFO_LENGTH_MISMATCH && bufferSize <= maxBufferSize);
} while ((status == STATUS_INFO_LENGTH_MISMATCH) &&
(bufferSize <= maxBufferSize));
}
else if (status == STATUS_INFO_LENGTH_MISMATCH) {
// Required length is stored in MaximumLength.
Expand Down

0 comments on commit d1cce5c

Please sign in to comment.