diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2023-04-21 10:55:36 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2023-04-21 12:14:44 +0200 |
commit | ef7ae66eef4e36e15b5248b926b4b020387d8101 (patch) | |
tree | 37d683a784dce3fcc3905ea71d6193ab5c1d0037 /src/nvim/api/vim.c | |
parent | 05928fe29814516be5537ffa23e8ba7a1f86e0be (diff) | |
download | rneovim-ef7ae66eef4e36e15b5248b926b4b020387d8101.tar.gz rneovim-ef7ae66eef4e36e15b5248b926b4b020387d8101.tar.bz2 rneovim-ef7ae66eef4e36e15b5248b926b4b020387d8101.zip |
fix(api): avoid integer truncation
gsrc/nvim/api/vim.c: In function ‘nvim_eval_statusline’:
gsrc/nvim/api/vim.c:2268:55: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-tru
ncation=]
2268 | snprintf(user_group, sizeof(user_group), "User%d", sp->userhl);
| ^~
gsrc/nvim/api/vim.c:2268:50: note: directive argument in the range [1, 2147483647]
2268 | snprintf(user_group, sizeof(user_group), "User%d", sp->userhl);
| ^~~~~~~~
In file included from /usr/include/stdio.h:906,
from gsrc/nvim/api/vim.c:9:
In function ‘snprintf’,
inlined from ‘nvim_eval_statusline’ at gsrc/nvim/api/vim.c:2268:9:
/usr/include/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 6 and 15 bytes into a destination of size 6
54 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
55 | __glibc_objsize (__s), __fmt,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
56 | __va_arg_pack ());
| ~~~~~~~~~~~~~~~~~
Diffstat (limited to 'src/nvim/api/vim.c')
-rw-r--r-- | src/nvim/api/vim.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index c8bb22b33c..d47f47e638 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -2241,7 +2241,7 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error * if (highlights) { Array hl_values = ARRAY_DICT_INIT; const char *grpname; - char user_group[6]; + char user_group[15]; // strlen("User") + strlen("2147483647") + NUL // If first character doesn't have a defined highlight, // add the default highlight at the beginning of the highlight list |