option: pvs/v557 (#14740)

Replace STRCAT with STRLCAT() to always NUL-terminate "errbuf" array.
This commit is contained in:
Jan Edmund Lazo 2021-08-08 17:27:50 -04:00 committed by GitHub
parent a2909aa35f
commit cdbd54972b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;