summaryrefslogtreecommitdiffstats
path: root/src/drawline.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-21 11:21:57 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-21 11:21:57 +0100
commit2b1ddf19f8f14365d0b998b4ac12ca85c0923475 (patch)
tree45b99a35fdf3c665d67ee7d94c0cd666f434cafe /src/drawline.c
parentf7c7aa3594b9f917b0b9571e1e60bef69b55244d (diff)
patch 9.0.0527: long sign text may overflow bufferv9.0.0527
Problem: Long sign text may overflow buffer. Solution: Use a larger buffer. Prevent for overflow.
Diffstat (limited to 'src/drawline.c')
-rw-r--r--src/drawline.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/drawline.c b/src/drawline.c
index c423756178..c77f88848c 100644
--- a/src/drawline.c
+++ b/src/drawline.c
@@ -124,7 +124,9 @@ typedef struct {
int saved_c_final;
int saved_char_attr;
- char_u extra[21]; // "%ld " and 'fdc' must fit in here
+ char_u extra[NUMBUFLEN + MB_MAXBYTES];
+ // "%ld " and 'fdc' must fit in here, as well
+ // any text sign
#ifdef FEAT_DIFF
hlf_T diff_hlf; // type of diff highlighting
@@ -259,13 +261,13 @@ get_sign_display_info(
{
if (nrcol)
{
- int n, width = number_width(wp) - 2;
+ int width = number_width(wp) - 2;
+ int n;
for (n = 0; n < width; n++)
wlv->extra[n] = ' ';
- wlv->extra[n] = 0;
- STRCAT(wlv->extra, wlv->p_extra);
- STRCAT(wlv->extra, " ");
+ vim_snprintf((char *)wlv->extra + n,
+ sizeof(wlv->extra) - n, "%s ", wlv->p_extra);
wlv->p_extra = wlv->extra;
}
wlv->c_extra = NUL;