aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
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
parent801deb07f6ecc6a3c8933cffc23d4b3a895259e1 (diff)
downloadglibc-05fe3ecffff485032e904f0a3ea709e24d9188eb.zip
glibc-05fe3ecffff485032e904f0a3ea709e24d9188eb.tar.gz
glibc-05fe3ecffff485032e904f0a3ea709e24d9188eb.tar.bz2
malloc: Assure that THP mode read do write OOB end of stringt
Diffstat (limited to 'sysdeps/unix')
-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 740027e..2f31647 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);