Mercurial > vim
changeset 10749:a7789921b514 v8.0.0264
patch 8.0.0264: memory error reported by ubsan
commit https://github.com/vim/vim/commit/d297f35eb0f6cfed47dd7ecf47df62994695a454
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jan 29 20:31:21 2017 +0100
patch 8.0.0264: memory error reported by ubsan
Problem: Memory error reported by ubsan, probably for using the string
returned by execute().
Solution: NUL terminate the result of execute().
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 29 Jan 2017 20:45:04 +0100 |
parents | a84910a9f7e1 |
children | bc18332a39a1 |
files | src/evalfunc.c src/version.c |
diffstat | 2 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -2819,7 +2819,17 @@ f_execute(typval_T *argvars, typval_T *r --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;