From 897b9ec28f8a6884b0b9e64b242b2fdaf16e7766 Mon Sep 17 00:00:00 2001 From: Hirbod Behnam Date: Tue, 26 Nov 2024 20:38:30 +0330 Subject: [PATCH 1/2] Fixed bufferoverflow in printint --- kernel/printf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/printf.c b/kernel/printf.c index d20534c150..7f7f2a0ce5 100644 --- a/kernel/printf.c +++ b/kernel/printf.c @@ -28,7 +28,7 @@ static char digits[] = "0123456789abcdef"; static void printint(long long xx, int base, int sign) { - char buf[16]; + char buf[20]; int i; unsigned long long x; From e1c4579c182120600a8f1cab6a60b2e5829d41a8 Mon Sep 17 00:00:00 2001 From: Hirbod Behnam Date: Sat, 18 Jan 2025 10:12:36 +0330 Subject: [PATCH 2/2] Fixed buffer overflow in userspace as well --- user/printf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user/printf.c b/user/printf.c index 81787467fa..6dc5863081 100644 --- a/user/printf.c +++ b/user/printf.c @@ -13,9 +13,9 @@ putc(int fd, char c) } static void -printint(int fd, int xx, int base, int sgn) +printint(int fd, long long xx, int base, int sgn) { - char buf[16]; + char buf[20]; int i, neg; uint x;