patch 9.2.0212: MS-Windows: version packing may overflow

Commit: 
https://github.com/vim/vim/commit/3ee2b76ba1c4f263a5f161da740cedbd3747a35a
Author: Mao-Yining <[email protected]>
Date:   Fri Mar 20 22:06:58 2026 +0000

    patch 9.2.0212: MS-Windows: version packing may overflow
    
    Problem:  MS-Windows: version packing may overflow (after v9.2.0206)
    Solution: Explicitly clamp the version components using min()
              (Mao-Yining).
    
    The version components (major, minor, build) from RtlGetVersion are now
    clamped to their maximum bit widths (8 bits, 8 bits, 15 bits) before
    being packed into a 32-bit integer. This prevents overflow when storing
    unexpectedly large values.
    
    This fixes a regression introduced in patch 9.2.0206 where the previous
    clamping logic was accidentally removed.
    
    The MAKE_VER macro is simplified by removing bit masks, as clamping is
    now done at the call site, making the macro clearer and reducing
    redundant masking.
    
    closes: #19769
    
    Signed-off-by: Mao-Yining <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/os_mswin.c b/src/os_mswin.c
index 6c92428a0..be71fac73 100644
--- a/src/os_mswin.c
+++ b/src/os_mswin.c
@@ -127,9 +127,9 @@ win_version_init(void)
 
     osver.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);
     pRtlGetVersion(&osver);
-    win_version =
-       MAKE_VER(osver.dwMajorVersion, osver.dwMinorVersion,
-                osver.dwBuildNumber);
+    win_version = MAKE_VER(min(osver.dwMajorVersion, 0xFF),
+           min(osver.dwMinorVersion, 0xFF),
+           min(osver.dwBuildNumber, 0xFFFF));
 }
 
 /*
diff --git a/src/os_win32.h b/src/os_win32.h
index 6eaa951e7..6f395eede 100644
--- a/src/os_win32.h
+++ b/src/os_win32.h
@@ -227,4 +227,4 @@ Trace(char *pszFormat, ...);
 
 // Windows Version
 #define MAKE_VER(major, minor, build) \
-    ((((major) & 0xFF) << 24) | (((minor) & 0xFF) << 16) | ((build) & 0x7FFF))
+    (((major) << 24) | ((minor) << 16) | (build))
diff --git a/src/version.c b/src/version.c
index f6eee5453..83c07847e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    212,
 /**/
     211,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1w3i7Y-00FMUH-BM%40256bit.org.

Raspunde prin e-mail lui