mirror of
https://github.com/vim/vim.git
synced 2026-05-28 00:21:37 +02:00
patch 9.2.0487: viminfo: possible signed int overflow in register array
Problem: viminfo: possible signed int overflow in register array growth Solution: Cast to size_t (Yasuhiro Matsumoto) The expression `limit * 2 * sizeof(string_T)` in read_viminfo_register() multiplies in int and overflows once limit exceeds INT_MAX/2. Cast to size_t first so the size computation stays unsigned. Defensive only; reaching this path requires registers consuming many gigabytes. closes: #20207 Signed-off-by: Yasuhiro Matsumoto <mattn.jp@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
de7a5b5425
commit
ee49669e8f
@@ -729,6 +729,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
487,
|
||||
/**/
|
||||
486,
|
||||
/**/
|
||||
|
||||
+1
-1
@@ -1706,7 +1706,7 @@ read_viminfo_register(vir_T *virp, int force)
|
||||
if (size == limit)
|
||||
{
|
||||
string_T *new_array = (string_T *)
|
||||
alloc(limit * 2 * sizeof(string_T));
|
||||
alloc((size_t)limit * 2 * sizeof(string_T));
|
||||
|
||||
if (new_array == NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user