-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Closed
Closed
Copy link
Labels
3.13bugs and security fixesbugs and security fixesOS-windowstopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
The cast in millis = (DWORD) (timeout / 1000000); may overflow because DWORD is an unsigned 32-bit integer and timeout is a 64-bit integer. We should clamp the result if the cast would overflow.
Lines 93 to 105 in cc7e45c
| static int | |
| _PySemaphore_PlatformWait(_PySemaphore *sema, _PyTime_t timeout) | |
| { | |
| int res; | |
| #if defined(MS_WINDOWS) | |
| DWORD wait; | |
| DWORD millis = 0; | |
| if (timeout < 0) { | |
| millis = INFINITE; | |
| } | |
| else { | |
| millis = (DWORD) (timeout / 1000000); | |
| } |
Noticed by @vstinner in #112733 (review)
Linked PRs
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixesOS-windowstopic-free-threadingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error