0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.3659: integer overflow with large line number

Problem:    Integer overflow with large line number.
Solution:   Check for overflow. (closes #9202)
This commit is contained in:
Bram Moolenaar
2021-11-24 12:17:53 +00:00
parent 48608b4a4b
commit 03725c5795
6 changed files with 65 additions and 7 deletions

View File

@@ -630,10 +630,14 @@ getcount:
del_from_showcmd(4); // delete the digit and ~@%
#endif
}
else
ca.count0 = ca.count0 * 10 + (c - '0');
if (ca.count0 < 0) // overflow
else if (ca.count0 >= 999999999L)
{
ca.count0 = 999999999L;
}
else
{
ca.count0 = ca.count0 * 10 + (c - '0');
}
#ifdef FEAT_EVAL
// Set v:count here, when called from main() and not a stuffed
// command, so that v:count can be used in an expression mapping
@@ -700,11 +704,14 @@ getcount:
* multiplied.
*/
if (ca.count0)
ca.count0 *= ca.opcount;
{
if (ca.opcount >= 999999999L / ca.count0)
ca.count0 = 999999999L;
else
ca.count0 *= ca.opcount;
}
else
ca.count0 = ca.opcount;
if (ca.count0 < 0) // overflow
ca.count0 = 999999999L;
}
/*