Commit: patch 9.1.1031: Coverity complains about insecure data handling

5 views
Skip to first unread message

Christian Brabandt

unread,
Jan 18, 2025, 4:45:11 AM1/18/25
to vim...@googlegroups.com
patch 9.1.1031: Coverity complains about insecure data handling

Commit: https://github.com/vim/vim/commit/5e9aaedf520e850470fdecebb1ceccba0956178e
Author: Yegappan Lakshmanan <yega...@yahoo.com>
Date: Sat Jan 18 10:24:25 2025 +0100

patch 9.1.1031: Coverity complains about insecure data handling

Problem: Coverity complains about insecure data handling
(v9.1.1024)
Solution: use int consistently to access the blob index
(Yegappan Lakshmanan)

related: #16468

Signed-off-by: Yegappan Lakshmanan <yega...@yahoo.com>
Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/src/fileio.c b/src/fileio.c
index 93e13e331..a2031e96f 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4308,7 +4308,7 @@ buf_check_timestamp(
*/
busy = TRUE;
#ifdef FEAT_EVAL
- set_vim_var_string(VV_FCS_REASON, (char_u *)reason, reasonlen);
+ set_vim_var_string(VV_FCS_REASON, (char_u *)reason, (int)reasonlen);
set_vim_var_string(VV_FCS_CHOICE, (char_u *)"", 0);
#endif
++allbuf_lock;
diff --git a/src/strings.c b/src/strings.c
index a71ac9192..53e0171aa 100644
--- a/src/strings.c
+++ b/src/strings.c
@@ -1265,7 +1265,7 @@ string_from_blob(blob_T *blob, long *start_idx)
{
garray_T str_ga;
long blen;
- long idx;
+ int idx;

ga_init2(&str_ga, sizeof(char), 80);

diff --git a/src/testdir/test_functions.vim b/src/testdir/test_functions.vim
index 5e0fd7da7..bf3e88916 100644
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -4282,6 +4282,9 @@ func Test_str2blob()
call assert_equal(0zABBB0AABBB, str2blob(['«»', '«»'], {'encoding': 'latin1'}))
call assert_equal(0zC2ABC2BB, str2blob(['«»'], {'encoding': 'utf8'}))

+ call assert_equal(0z62, str2blob(["b"], test_null_dict()))
+ call assert_equal(0z63, str2blob(["c"], {'encoding': test_null_string()}))
+
call assert_fails("call str2blob(['abc'], [])", 'E1206: Dictionary required for argument 2')
call assert_fails("call str2blob(['abc'], {'encoding': []})", 'E730: Using a List as a String')
call assert_fails("call str2blob(['abc'], {'encoding': 'ab12xy'})", 'E1515: Unable to convert to ''ab12xy'' encoding')
diff --git a/src/version.c b/src/version.c
index 43a84e8b9..d273ce725 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1031,
/**/
1030,
/**/
Reply all
Reply to author
Forward
0 new messages