Commit: patch 9.2.0212: MS-Windows: version packing may overflow

0 views
Skip to first unread message

Christian Brabandt

unread,
Mar 20, 2026, 6:17:11 PM (3 days ago) Mar 20
to vim...@googlegroups.com
patch 9.2.0212: MS-Windows: version packing may overflow

Commit: https://github.com/vim/vim/commit/3ee2b76ba1c4f263a5f161da740cedbd3747a35a
Author: Mao-Yining <mao.y...@outlook.com>
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 <mao.y...@outlook.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

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,
/**/
Reply all
Reply to author
Forward
0 new messages