[newlib-cygwin/cygwin-3_6-branch] Cygwin: dll_init: use SIZE_T instead of DWORD for size

Jeremy Drake via Cygwin-cvs <[email protected]>
Newsgroups gmane.os.cygwin.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=88d3ddbe2ba13815d14e5481a97c249a4c573d98

commit 88d3ddbe2ba13815d14e5481a97c249a4c573d98
Author: Jeremy Drake <[email protected]>
Date:   Thu May 22 10:06:29 2025 -0700

    Cygwin: dll_init: use SIZE_T instead of DWORD for size
    
    The RegionSize member of the MEMORY_BASIC_INFORMATION struct is of type
    SIZE_T, and it may be larger than will fit in a DWORD (I observed
    0x200000000).  This resulted in an error due to trying to reserve 0
    bytes from VirtualAllloc.
    
    Fixes: 8d777a13fcf4 ("* dll_init.cc (reserve_at, release_at): New functions.")
    Addresses: https://cygwin.com/pipermail/cygwin/2025-May/258154.html
    Reported-by: Yuyi Wang <[email protected]>
    Signed-off-by: Jeremy Drake <[email protected]>

Diff:
---
 winsup/cygwin/dll_init.cc   | 2 +-
 winsup/cygwin/release/3.6.2 | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc
index b8f38b56d..1369165c9 100644
--- a/winsup/cygwin/dll_init.cc
+++ b/winsup/cygwin/dll_init.cc
@@ -633,7 +633,7 @@ dll_list::track_self ()
 static PVOID
 reserve_at (PCWCHAR name, PVOID here, PVOID dll_base, DWORD dll_size)
 {
-  DWORD size;
+  SIZE_T size;
   MEMORY_BASIC_INFORMATION mb;
 
   if (!VirtualQuery (here, &mb, sizeof (mb)))
diff --git a/winsup/cygwin/release/3.6.2 b/winsup/cygwin/release/3.6.2
index 3b1944d99..16a4fee15 100644
--- a/winsup/cygwin/release/3.6.2
+++ b/winsup/cygwin/release/3.6.2
@@ -28,3 +28,6 @@ Fixes:
 
 - Fix infinite exception loop on segmentation fault when strace-ing
   Addresses: https://cygwin.com/pipermail/cygwin/2025-May/258144.html
+
+- Fix size truncation in dll_init reserve_at function.
+  Addresses: https://cygwin.com/pipermail/cygwin/2025-May/258154.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.