This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Use statfs64() in shm_open() and posix_getpt().
- From: Peter TB Brett <peter at peter-b dot co dot uk>
- To: libc-alpha at sourceware dot org
- Cc: Peter TB Brett <peter at peter-b dot co dot uk>
- Date: Sun, 13 Apr 2014 08:26:18 +0100
- Subject: [PATCH] Use statfs64() in shm_open() and posix_getpt().
- Authentication-results: sourceware.org; auth=none
Philip Guenther noted in [BZ 15514] that statfs() may EOVERFLOW when
running 32-bit programs on 64-bit systems, and that shm_open() and
posix_getpt() may be affected.
This patch modifies shm_open() and posix_getpt() to use statfs64()
instead of __statfs().
Reported-by: Philip Guenther <guenther@gmail.com>
---
ChangeLog | 9 +++++++++
sysdeps/unix/sysv/linux/getpt.c | 6 +++---
sysdeps/unix/sysv/linux/shm_open.c | 6 +++---
3 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index a42e08e..4e52aa8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-04-13 Peter Brett <peter@peter-b.co.uk>
+
+ [BZ 15514]
+ * sysdeps/unix/sysv/linux/shm_open.c (where_is_shmfs): Check for
+ shmfs using statfs64().
+ * sysdeps/unix/sysv/linux/getpt.c (__posix_openpt): Check for
+ /dev/pts and devfs using statfs64().
+ Reported by Philip Guenther <guenther@gmail.com>
+
2014-04-12 Allan McRae <allan@archlinux.org>
[BZ #16838]
diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c
index cea2fa6..c8f9275 100644
--- a/sysdeps/unix/sysv/linux/getpt.c
+++ b/sysdeps/unix/sysv/linux/getpt.c
@@ -46,15 +46,15 @@ __posix_openpt (oflag)
fd = __open (_PATH_DEVPTMX, oflag);
if (fd != -1)
{
- struct statfs fsbuf;
+ struct statfs64 fsbuf;
static int devpts_mounted;
/* Check that the /dev/pts filesystem is mounted
or if /dev is a devfs filesystem (this implies /dev/pts). */
if (devpts_mounted
- || (__statfs (_PATH_DEVPTS, &fsbuf) == 0
+ || (statfs64 (_PATH_DEVPTS, &fsbuf) == 0
&& fsbuf.f_type == DEVPTS_SUPER_MAGIC)
- || (__statfs (_PATH_DEV, &fsbuf) == 0
+ || (statfs64 (_PATH_DEV, &fsbuf) == 0
&& fsbuf.f_type == DEVFS_SUPER_MAGIC))
{
/* Everything is ok. */
diff --git a/sysdeps/unix/sysv/linux/shm_open.c b/sysdeps/unix/sysv/linux/shm_open.c
index cec6fdb..a41b6b5 100644
--- a/sysdeps/unix/sysv/linux/shm_open.c
+++ b/sysdeps/unix/sysv/linux/shm_open.c
@@ -55,14 +55,14 @@ static void
where_is_shmfs (void)
{
char buf[512];
- struct statfs f;
+ struct statfs64 f;
struct mntent resmem;
struct mntent *mp;
FILE *fp;
/* The canonical place is /dev/shm. This is at least what the
documentation tells everybody to do. */
- if (__statfs (defaultdir, &f) == 0 && (f.f_type == SHMFS_SUPER_MAGIC
+ if (statfs64 (defaultdir, &f) == 0 && (f.f_type == SHMFS_SUPER_MAGIC
|| f.f_type == RAMFS_MAGIC))
{
/* It is in the normal place. */
@@ -97,7 +97,7 @@ where_is_shmfs (void)
/* First make sure this really is the correct entry. At least
some versions of the kernel give wrong information because
of the implicit mount of the shmfs for SysV IPC. */
- if (__statfs (mp->mnt_dir, &f) != 0 || (f.f_type != SHMFS_SUPER_MAGIC
+ if (statfs64 (mp->mnt_dir, &f) != 0 || (f.f_type != SHMFS_SUPER_MAGIC
&& f.f_type != RAMFS_MAGIC))
continue;
--
1.9.0