vim-patch:8.2.3659: integer overflow with large line number

Problem:    Integer overflow with large line number.
Solution:   Check for overflow. (closes vim/vim#9202)
03725c5795

Put E1247 in globals.h as E1240 is also there.
Do not make getdigits() abort.
This commit is contained in:
zeertzjq
2022-02-18 08:29:55 +08:00
parent 592f4a7c08
commit 3ed800e998
6 changed files with 85 additions and 11 deletions

View File

@@ -4141,7 +4141,11 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
if (!ascii_isdigit(*cmd)) { // '+' is '+1', but '+0' is not '+1'
n = 1;
} else {
n = getdigits(&cmd, true, 0);
n = getdigits(&cmd, false, MAXLNUM);
if (n == MAXLNUM) {
emsg(_(e_line_number_out_of_range));
goto error;
}
}
if (addr_type == ADDR_TABS_RELATIVE) {
@@ -4160,6 +4164,10 @@ static linenr_T get_address(exarg_T *eap, char_u **ptr, cmd_addr_T addr_type, in
if (i == '-') {
lnum -= n;
} else {
if (n >= LONG_MAX - lnum) {
emsg(_(e_line_number_out_of_range));
goto error;
}
lnum += n;
}
}