[PATCH 12/37] autofs-5.1.2 - Fix fgets(3) size argument (another one)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tomohiro Kusumi <kusumi.tomohiro@xxxxxxxxx>

1. fgets(3) reads at most 1 less then the size argument.
2. Each line of /proc/filesystem isn't a filesystem path.

So it doesn't really matter if the size argument is PATH_MAX-1
or PATH_MAX (=sizeof(buf)) as long as the buffer is large enough.
We can just use sizeof(buf).

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@xxxxxxxxx>
Signed-off-by: Ian Kent <raven@xxxxxxxxxx>
---
 CHANGELOG       |    1 +
 daemon/module.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/CHANGELOG b/CHANGELOG
index a0a2c46..28e857f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -11,6 +11,7 @@ xx/xx/2016 autofs-5.1.3
 - fix file map changed check.
 - Remove unused local 2KB buffer.
 - Fix typos in error messages.
+- Fix fgets(3) size argument (another one).
 
 15/06/2016 autofs-5.1.2
 =======================
diff --git a/daemon/module.c b/daemon/module.c
index db01db8..8879b64 100644
--- a/daemon/module.c
+++ b/daemon/module.c
@@ -38,7 +38,7 @@ int load_autofs4_module(void)
 		return 0;
 	}
 
-	while (fgets(buf, PATH_MAX - 1, fp)) {
+	while (fgets(buf, sizeof(buf), fp)) {
 		if (strstr(buf, "autofs")) {
 			fclose(fp);
 			return 1;

--
To unsubscribe from this list: send the line "unsubscribe autofs" in



[Index of Archives]     [Linux Filesystem Development]     [Linux Ext4]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux