From cdbd54972bb96fa8288301a528b02254fd0b4261 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 8 Aug 2021 17:27:50 -0400 Subject: [PATCH] option: pvs/v557 (#14740) Replace STRCAT with STRLCAT() to always NUL-terminate "errbuf" array. --- src/nvim/option.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/nvim/option.c b/src/nvim/option.c index a4b33118cf..c3f9909b9d 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -1408,22 +1408,19 @@ int do_set( *errbuf = NUL; i = getdigits_int(&arg, true, 0); if (i & 1) { - STRCAT(errbuf, "b,"); + STRLCAT(errbuf, "b,", sizeof(errbuf)); } if (i & 2) { - STRCAT(errbuf, "s,"); + STRLCAT(errbuf, "s,", sizeof(errbuf)); } if (i & 4) { - STRCAT(errbuf, "h,l,"); + STRLCAT(errbuf, "h,l,", sizeof(errbuf)); } if (i & 8) { - STRCAT(errbuf, "<,>,"); + STRLCAT(errbuf, "<,>,", sizeof(errbuf)); } if (i & 16) { - STRCAT(errbuf, "[,],"); - } - if (*errbuf != NUL) { // remove trailing , - errbuf[STRLEN(errbuf) - 1] = NUL; + STRLCAT(errbuf, "[,],", sizeof(errbuf)); } save_arg = arg; arg = errbuf;