aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-04-29 21:12:42 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-04-29 21:19:45 +0200
commit035a41c21827e616ec2abba581329bea4201da88 (patch)
tree950a48a94d0cbaf1b8b0fff436d5eb645533c2f7
parent3a92040b443edfbf0f7c9423c865e5a013b07d62 (diff)
downloadrneovim-035a41c21827e616ec2abba581329bea4201da88.tar.gz
rneovim-035a41c21827e616ec2abba581329bea4201da88.tar.bz2
rneovim-035a41c21827e616ec2abba581329bea4201da88.zip
vim-patch:8.1.0325: strings in swap file may not be NUL terminated
Problem: Strings in swap file may not be NUL terminated. (Coverity) Solution: Limit the length of the used string. https://github.com/vim/vim/commit/7c60505e1012a43549c2c075c27463c5399e81ec
-rw-r--r--src/nvim/memline.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/nvim/memline.c b/src/nvim/memline.c
index cbe4ce625a..7e15627292 100644
--- a/src/nvim/memline.c
+++ b/src/nvim/memline.c
@@ -1472,10 +1472,14 @@ void get_b0_dict(const char *fname, dict_T *d)
tv_dict_add_str(d, S_LEN("error"), xstrdup("Magic number mismatch"));
} else {
// We have swap information.
- tv_dict_add_str(d, S_LEN("version"), xstrdup((char *)b0.b0_version));
- tv_dict_add_str(d, S_LEN("user"), xstrdup((char *)b0.b0_uname));
- tv_dict_add_str(d, S_LEN("host"), xstrdup((char *)b0.b0_hname));
- tv_dict_add_str(d, S_LEN("fname"), xstrdup((char *)b0.b0_fname));
+ tv_dict_add_str(d, S_LEN("version"),
+ xstrndup((char *)b0.b0_version, 10));
+ tv_dict_add_str(d, S_LEN("user"),
+ xstrndup((char *)b0.b0_uname, B0_UNAME_SIZE));
+ tv_dict_add_str(d, S_LEN("host"),
+ xstrndup((char *)b0.b0_hname, B0_HNAME_SIZE));
+ tv_dict_add_str(d, S_LEN("fname"),
+ xstrndup((char *)b0.b0_fname, B0_FNAME_SIZE_ORG));
tv_dict_add_nr(d, S_LEN("pid"), char_to_long(b0.b0_pid));
tv_dict_add_nr(d, S_LEN("mtime"), char_to_long(b0.b0_mtime));