From 05fe3ecffff485032e904f0a3ea709e24d9188eb Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Fri, 14 Apr 2023 08:22:40 -0300 Subject: [PATCH] malloc: Assure that THP mode read do write OOB end of stringt --- sysdeps/unix/sysv/linux/malloc-hugepages.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sysdeps/unix/sysv/linux/malloc-hugepages.c b/sysdeps/unix/sysv/linux/malloc-hugepages.c index 740027ebfb..2f316474c1 100644 --- a/sysdeps/unix/sysv/linux/malloc-hugepages.c +++ b/sysdeps/unix/sysv/linux/malloc-hugepages.c @@ -61,6 +61,8 @@ __malloc_thp_mode (void) char str[sizeof(mode_always)]; ssize_t s = __read_nocancel (fd, str, sizeof (str)); + if (s >= sizeof str || s < 0) + return malloc_thp_mode_not_supported; str[s] = '\0'; __close_nocancel (fd); -- 2.34.1