Re: [PATCH] automount: Fix size arg of fgets(3)

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

 



On Mon, 2016-07-04 at 23:31 +0900, Tomohiro Kusumi wrote:
> 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.

And also added.

> 
> Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@xxxxxxxxx>
> ---
>  lib/defaults.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/defaults.c b/lib/defaults.c
> index 0e48a78..ae76513 100644
> --- a/lib/defaults.c
> +++ b/lib/defaults.c
> @@ -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) {
--
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