]> granicus.if.org Git - vim/commitdiff
patch 8.1.0325: strings in swap file may not be NUL terminated v8.1.0325
authorBram Moolenaar <Bram@vim.org>
Thu, 23 Aug 2018 21:01:27 +0000 (23:01 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 23 Aug 2018 21:01:27 +0000 (23:01 +0200)
Problem:    Strings in swap file may not be NUL terminated. (Coverity)
Solution:   Limit the length of the used string.

src/memline.c
src/version.c

index 3d82af0813e4935324c81de1050c8bd5f528d4fd..b4e02d7716ed489734a97de2172d197dbb22c3df 100644 (file)
@@ -2065,10 +2065,13 @@ get_b0_dict(char_u *fname, dict_T *d)
            else
            {
                /* we have swap information */
-               dict_add_string(d, "version", vim_strsave(b0.b0_version));
-               dict_add_string(d, "user", vim_strsave(b0.b0_uname));
-               dict_add_string(d, "host", vim_strsave(b0.b0_hname));
-               dict_add_string(d, "fname", vim_strsave(b0.b0_fname));
+               dict_add_string(d, "version", vim_strnsave(b0.b0_version, 10));
+               dict_add_string(d, "user",
+                                    vim_strnsave(b0.b0_uname, B0_UNAME_SIZE));
+               dict_add_string(d, "host",
+                                    vim_strnsave(b0.b0_hname, B0_HNAME_SIZE));
+               dict_add_string(d, "fname",
+                                vim_strnsave(b0.b0_fname, B0_FNAME_SIZE_ORG));
 
                dict_add_number(d, "pid", char_to_long(b0.b0_pid));
                dict_add_number(d, "mtime", char_to_long(b0.b0_mtime));
index bf40df79e98e6ff9ee4f3d4431c5bddadac6ec05..dfb09653e3da75d81e9fe59f9ed058d866d453f9 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    325,
 /**/
     324,
 /**/