To: vim_dev@googlegroups.com Subject: Patch 8.2.0892 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.0892 Problem: Ubsan warns for undefined behavior. Solution: Use unsigned instead of signed variable. (Dominique Pelle, closes #6193) Files: src/regexp_nfa.c *** ../vim-8.2.0891/src/regexp_nfa.c 2020-04-12 19:37:13.522297249 +0200 --- src/regexp_nfa.c 2020-06-03 18:53:55.865924727 +0200 *************** *** 246,251 **** --- 246,252 ---- static char_u e_nul_found[] = N_("E865: (NFA) Regexp end encountered prematurely"); static char_u e_misplaced[] = N_("E866: (NFA regexp) Misplaced %c"); static char_u e_ill_char_class[] = N_("E877: (NFA regexp) Invalid character class: %d"); + static char_u e_value_too_large[] = N_("E951: \\% value too large"); // Variables only used in nfa_regcomp() and descendants. static int nfa_re_flags; // re_flags passed to nfa_regcomp() *************** *** 1541,1559 **** default: { ! long n = 0; int cmp = c; if (c == '<' || c == '>') c = getchr(); while (VIM_ISDIGIT(c)) { ! n = n * 10 + (c - '0'); c = getchr(); } if (c == 'l' || c == 'c' || c == 'v') { ! int limit = INT_MAX; if (c == 'l') { --- 1542,1568 ---- default: { ! long_u n = 0; int cmp = c; if (c == '<' || c == '>') c = getchr(); while (VIM_ISDIGIT(c)) { ! long_u tmp = n * 10 + (c - '0'); ! ! if (tmp < n) ! { ! // overflow. ! emsg(_(e_value_too_large)); ! return FAIL; ! } ! n = tmp; c = getchr(); } if (c == 'l' || c == 'c' || c == 'v') { ! long_u limit = INT_MAX; if (c == 'l') { *************** *** 1576,1582 **** } if (n >= limit) { ! emsg(_("E951: \\% value too large")); return FAIL; } EMIT((int)n); --- 1585,1591 ---- } if (n >= limit) { ! emsg(_(e_value_too_large)); return FAIL; } EMIT((int)n); *** ../vim-8.2.0891/src/version.c 2020-06-03 10:04:45.720521241 +0200 --- src/version.c 2020-06-03 18:51:40.878409116 +0200 *************** *** 748,749 **** --- 748,751 ---- { /* Add new patch number below this line */ + /**/ + 892, /**/ -- XML is a nice language for computers. Not for humans. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///