]> granicus.if.org Git - vim/commitdiff
patch 8.2.3875: gcc complains about buffer overrun v8.2.3875
authorBram Moolenaar <Bram@vim.org>
Wed, 22 Dec 2021 20:29:09 +0000 (20:29 +0000)
committerBram Moolenaar <Bram@vim.org>
Wed, 22 Dec 2021 20:29:09 +0000 (20:29 +0000)
Problem:    gcc complains about buffer overrun.
Solution:   Use mch_memmove() instead of STRCPY(). (John Marriott)

src/dict.c
src/version.c

index f2989fff21e47decf4a23ab560d434021e3fb0a0..b49005ab4f96eb1774bd8a0594355b4ccddce21a 100644 (file)
@@ -222,11 +222,12 @@ dict_free_items(int copyID)
 dictitem_alloc(char_u *key)
 {
     dictitem_T *di;
+    size_t len = STRLEN(key);
 
-    di = alloc(offsetof(dictitem_T, di_key) + STRLEN(key) + 1);
+    di = alloc(offsetof(dictitem_T, di_key) + len + 1);
     if (di != NULL)
     {
-       STRCPY(di->di_key, key);
+       mch_memmove(di->di_key, key, len + 1);
        di->di_flags = DI_FLAGS_ALLOC;
        di->di_tv.v_lock = 0;
        di->di_tv.v_type = VAR_UNKNOWN;
index 072e88431b6e6c53df22fe5494d307c95e2b3938..87ec33c607fa08848e2d5b739c11ef8912450851 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3875,
 /**/
     3874,
 /**/