automount: Fix size arg of fgets(3)
Subsystems (2)
PATCH 1/1 automount: Fix size arg of fgets(3)
Since fgets(3) reads at most 1 less than size arg, it should probably pass MAX_LINE_LEN+1 given that the conditional in the next line tests if strlen() exceeds MAX_LINE_LEN. (i.e. MAX_LINE_LEN isn't designed to include terminating \0)
buf has MAX_LINE_LEN+2 bytes, so passing MAX_LINE_LEN+1 is ok.
--- lib/defaults.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/defaults.c +1 -1
@@ -879,7 +879,7 @@ static int read_config(unsigned int to_syslog, FILE *f, const char *name)char *res; new_sec =NULL ; -while ((res =fgets (buf,MAX_LINE_LEN , f))) { +while ((res =fgets (buf,MAX_LINE_LEN +1 , f))) {char *sec, *key, *value;if (strlen (res) >MAX_LINE_LEN ) {
Signature · 4 lines
2.5.5 -- To unsubscribe from this list: send the line "unsubscribe autofs" in
Ian Kent
maintainerQuoted 6 lines · Tomohiro Kusumi
Since fgets(3) reads at most 1 less than size arg, it should probably pass MAX_LINE_LEN+1 given that the conditional in the next line tests if
strlen()exceedsMAX_LINE_LEN. (i.e.MAX_LINE_LENisn't designed to include terminating \0)buf has MAX_LINE_LEN+2 bytes, so passing MAX_LINE_LEN+1 is ok.
And also added.
Quoted 19 lines
Signed-off-by Tomohiro Kusumi <[email protected]>--- lib/defaults.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/defaults.c +1
-1@@ -879,7 +879,7 @@ static int read_config(unsigned int to_syslog, FILE *f, const char *name) char *res; new_sec =NULL ; -while ((res =fgets (buf,MAX_LINE_LEN , f))) { +while ((res =fgets (buf,MAX_LINE_LEN +1 , f))) {char *sec, *key, *value;
Quoted 1 line
if (strlen(res) >
MAX_LINE_LEN) {
--
To unsubscribe from this list: send the line "unsubscribe autofs" in