make_aligned_titles: pass the correct buffer length

The third parameter to wcstombs() is the length of the output buffer
(first parameter) in bytes. Take the correct sizeof() here.

This is not a problem in practice, but prevents _FORTIFY_SOURCE=3 from
detecting a possible output buffer overflow (as the source buffer is
bigger than the destination).

Fixes #104.

Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name>
This commit is contained in:
Ivan Shapovalov 2024-03-13 04:27:31 +01:00
parent 95f148c222
commit 5e0496260b

View file

@ -140,7 +140,7 @@ static void make_aligned_titles(void)
size_t padlen = maxcol - wcol[i];
wmemset(wbuf[i] + wlen[i], L' ', padlen);
wmemcpy(wbuf[i] + wlen[i] + padlen, title_suffix, ARRAYSIZE(title_suffix));
wcstombs(titles[i], wbuf[i], sizeof(wbuf[i]));
wcstombs(titles[i], wbuf[i], sizeof(titles[i]));
}
}