mirror of
https://github.com/vim/vim.git
synced 2026-05-28 00:21:37 +02:00
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.yining@outlook.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
c4d2fa018c
commit
3ee2b76ba1
+3
-3
@@ -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));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
+1
-1
@@ -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))
|
||||
|
||||
@@ -734,6 +734,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
212,
|
||||
/**/
|
||||
211,
|
||||
/**/
|
||||
|
||||
Reference in New Issue
Block a user