]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.4298: divide by zero with huge tabstop value v8.2.4298
authorBram Moolenaar <Bram@vim.org>
Sat, 5 Feb 2022 11:13:05 +0000 (11:13 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 5 Feb 2022 11:13:05 +0000 (11:13 +0000)
Problem:    Divide by zero with huge tabstop value.
Solution:   Reject tabstop value that overflows to zero.

src/indent.c
src/testdir/test_vartabs.vim
src/version.c

index b62308d2a46de2606d843da6b2ea1bcac43c8cee..9b137b0b425a942506e96cc75a4077e95a183c09 100644 (file)
@@ -71,7 +71,7 @@ tabstop_set(char_u *var, int **array)
        int n = atoi((char *)cp);
 
        // Catch negative values, overflow and ridiculous big values.
-       if (n < 0 || n > TABSTOP_MAX)
+       if (n <= 0 || n > TABSTOP_MAX)
        {
            semsg(_(e_invalid_argument_str), cp);
            vim_free(*array);
index 3b8a9ce0b1ab9ec4f076a31afb3a1bc731858c17..156233dca70d890c3e433c514f834e412eaaaa4d 100644 (file)
@@ -146,6 +146,16 @@ func Test_vartabs()
   bwipeout!
 endfunc
 
+func Test_retab_invalid_arg()
+  new
+  call setline(1, "\ttext")
+  retab 0
+  call assert_fails("retab -8", 'E487: Argument must be positive')
+  call assert_fails("retab 10000", 'E475:')
+  call assert_fails("retab 720575940379279360", 'E475:')
+  bwipe!
+endfunc
+
 func Test_vartabs_breakindent()
   CheckOption breakindent
   new
index 95f2b5fd39336d20f44e0962a10a45f9742b9c3a..7df9eaa7af873211c1f2860d6a1516fecc0e7f5a 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4298,
 /**/
     4297,
 /**/