summaryrefslogtreecommitdiff
path: root/sysdeps/unix/sysv
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-04-14 08:22:40 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-04-14 08:22:40 -0300
commit05fe3ecffff485032e904f0a3ea709e24d9188eb (patch)
tree92516ab41f37af31dd2d33217e1547e4333701ec /sysdeps/unix/sysv
parent801deb07f6ecc6a3c8933cffc23d4b3a895259e1 (diff)
downloadglibc-05fe3ecffff485032e904f0a3ea709e24d9188eb.tar.gz
malloc: Assure that THP mode read do write OOB end of stringt
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/malloc-hugepages.c2
1 files changed, 2 insertions, 0 deletions
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);