From: Adhemerval Zanella Date: Fri, 14 Apr 2023 11:22:40 +0000 (-0300) Subject: malloc: Assure that THP mode read do write OOB end of stringt X-Git-Tag: glibc-2.38~374 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=05fe3ecffff485032e904f0a3ea709e24d9188eb;p=glibc.git malloc: Assure that THP mode read do write OOB end of stringt --- 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);