Skip to content

Commit a8f2f93

Browse files
authored
Merge pull request #38 from pspdev/fix-buffer-overflow
Fix buffer overflow when running -Qi in Ubuntu 25.10
2 parents a62b15e + 59cc876 commit a8f2f93

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

pacman.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ find ./ -type f -name "*.in" -exec sed -i -e 's#@libmakepkgdir@#${PSPDEV}/share/
3333

3434
## Apply patch
3535
apply_patch pacman-${PACMAN_VERSION}
36+
apply_patch 147 # Fixes https://github.com/pspdev/psp-pacman/issues/37
3637

3738
## Install meson and ninja in the current directory
3839
setup_build_system

patches/147.patch

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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

Comments
 (0)