|
| 1 | +From 5e0496260b7d3f9c9fcf2b1c4899e4dbcc20ff03 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ivan Shapovalov <intelfx@intelfx.name> |
| 3 | +Date: Wed, 13 Mar 2024 04:27:31 +0100 |
| 4 | +Subject: [PATCH] make_aligned_titles: pass the correct buffer length |
| 5 | + |
| 6 | +The third parameter to wcstombs() is the length of the output buffer |
| 7 | +(first parameter) in bytes. Take the correct sizeof() here. |
| 8 | + |
| 9 | +This is not a problem in practice, but prevents _FORTIFY_SOURCE=3 from |
| 10 | +detecting a possible output buffer overflow (as the source buffer is |
| 11 | +bigger than the destination). |
| 12 | + |
| 13 | +Fixes #104. |
| 14 | + |
| 15 | +Signed-off-by: Ivan Shapovalov <intelfx@intelfx.name> |
| 16 | +--- |
| 17 | + src/pacman/package.c | 2 +- |
| 18 | + 1 file changed, 1 insertion(+), 1 deletion(-) |
| 19 | + |
| 20 | +diff --git a/src/pacman/package.c b/src/pacman/package.c |
| 21 | +index b832663c0..95d0c4c4c 100644 |
| 22 | +--- a/src/pacman/package.c |
| 23 | ++++ b/src/pacman/package.c |
| 24 | +@@ -140,7 +140,7 @@ static void make_aligned_titles(void) |
| 25 | + size_t padlen = maxcol - wcol[i]; |
| 26 | + wmemset(wbuf[i] + wlen[i], L' ', padlen); |
| 27 | + wmemcpy(wbuf[i] + wlen[i] + padlen, title_suffix, ARRAYSIZE(title_suffix)); |
| 28 | +- wcstombs(titles[i], wbuf[i], sizeof(wbuf[i])); |
| 29 | ++ wcstombs(titles[i], wbuf[i], sizeof(titles[i])); |
| 30 | + } |
| 31 | + } |
| 32 | + |
| 33 | +-- |
| 34 | +GitLab |
| 35 | + |
0 commit comments