mailing list of musl libc
 help / color / mirror / code / Atom feed
* [PATCH] increase buffer size in getmntent to 4096 bytes
@ 2016-10-17 10:24 Rostislav Skudnov
  2016-10-17 12:48 ` Natanael Copa
  0 siblings, 1 reply; 3+ messages in thread
From: Rostislav Skudnov @ 2016-10-17 10:24 UTC (permalink / raw)
  To: musl

getmntent fails if the length of the mount entry exceeds the buffer
size. The new buffer size matches that of glibc.
---
Even after this patch, getmntent may still fail since the device and mount
paths may be up to PATH_MAX in length, and the mount options may
(theoretically) have unlimited length. The same would happen in glibc, though.

 src/misc/mntent.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/misc/mntent.c b/src/misc/mntent.c
index a16d652..5adb583 100644
--- a/src/misc/mntent.c
+++ b/src/misc/mntent.c
@@ -49,7 +49,7 @@ struct mntent *getmntent_r(FILE *f, struct mntent *mnt, char *linebuf, int bufle
 
 struct mntent *getmntent(FILE *f)
 {
-	static char linebuf[256];
+	static char linebuf[4096];
 	static struct mntent mnt;
 	return getmntent_r(f, &mnt, linebuf, sizeof linebuf);
 }
-- 
2.1.4



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] increase buffer size in getmntent to 4096 bytes
  2016-10-17 10:24 [PATCH] increase buffer size in getmntent to 4096 bytes Rostislav Skudnov
@ 2016-10-17 12:48 ` Natanael Copa
  2016-10-17 20:29   ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Natanael Copa @ 2016-10-17 12:48 UTC (permalink / raw)
  To: Rostislav Skudnov; +Cc: musl

On Mon, 17 Oct 2016 10:24:25 +0000
Rostislav Skudnov <rostislav@tuxera.com> wrote:

> getmntent fails if the length of the mount entry exceeds the buffer
> size. The new buffer size matches that of glibc.
> ---
> Even after this patch, getmntent may still fail since the device and mount
> paths may be up to PATH_MAX in length, and the mount options may
> (theoretically) have unlimited length. The same would happen in glibc, though.

This patch solve the same problem, but uses getline to malloc the buffer as needed:
http://www.openwall.com/lists/musl/2016/09/08/1


-nc


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] increase buffer size in getmntent to 4096 bytes
  2016-10-17 12:48 ` Natanael Copa
@ 2016-10-17 20:29   ` Rich Felker
  0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2016-10-17 20:29 UTC (permalink / raw)
  To: musl

On Mon, Oct 17, 2016 at 02:48:17PM +0200, Natanael Copa wrote:
> On Mon, 17 Oct 2016 10:24:25 +0000
> Rostislav Skudnov <rostislav@tuxera.com> wrote:
> 
> > getmntent fails if the length of the mount entry exceeds the buffer
> > size. The new buffer size matches that of glibc.
> > ---
> > Even after this patch, getmntent may still fail since the device and mount
> > paths may be up to PATH_MAX in length, and the mount options may
> > (theoretically) have unlimited length. The same would happen in glibc, though.
> 
> This patch solve the same problem, but uses getline to malloc the buffer as needed:
> http://www.openwall.com/lists/musl/2016/09/08/1

Indeed. We can't go making every program use an additional page of
memory just for a rare program that uses getmntent, so dynamic
allocation it had to be.

Rich


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-17 20:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-17 10:24 [PATCH] increase buffer size in getmntent to 4096 bytes Rostislav Skudnov
2016-10-17 12:48 ` Natanael Copa
2016-10-17 20:29   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).