]> granicus.if.org Git - vim/commitdiff
patch 8.0.0264: memory error reported by ubsan v8.0.0264
authorBram Moolenaar <Bram@vim.org>
Sun, 29 Jan 2017 19:31:21 +0000 (20:31 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 29 Jan 2017 19:31:21 +0000 (20:31 +0100)
Problem:    Memory error reported by ubsan, probably for using the string
            returned by execute().
Solution:   NUL terminate the result of execute().

src/evalfunc.c
src/version.c

index 6706fe17b7335426ea89f75f6e82fbcce88e79cc..7f433a5a6fe47a0180a5244c8894c5b137073985 100644 (file)
@@ -2819,7 +2819,17 @@ f_execute(typval_T *argvars, typval_T *rettv)
        --list->lv_refcount;
     }
 
-    rettv->vval.v_string = redir_execute_ga.ga_data;
+    /* Need to append a NUL to the result. */
+    if (ga_grow(&redir_execute_ga, 1) == OK)
+    {
+       ((char *)redir_execute_ga.ga_data)[redir_execute_ga.ga_len] = NUL;
+       rettv->vval.v_string = redir_execute_ga.ga_data;
+    }
+    else
+    {
+       ga_clear(&redir_execute_ga);
+       rettv->vval.v_string = NULL;
+    }
     msg_silent = save_msg_silent;
     emsg_silent = save_emsg_silent;
     emsg_noredir = save_emsg_noredir;
index 67fe69b7a8fa1b644b28f52edc004cbb1609319b..5431022f469714ea77bc0f69e04a01e5fc6acf99 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    264,
 /**/
     263,
 /**/