Re: [PATCH 2/3] nfs-utils: NULL-terminate buffer after read in read_service_info

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

 



On Sat,  7 Mar 2009 07:45:27 -0500
Jeff Layton <jlayton@xxxxxxxxxx> wrote:

> Valgrind complains that we're passing an unintialized buffer to
> sscanf here. The main problem seems to be that we're not ensuring
> that the buffer is NULL terminated before we pass it off.
> 
> Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
> ---
>  utils/gssd/gssd_proc.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c
> index d0d3f7f..0ebdfcd 100644
> --- a/utils/gssd/gssd_proc.c
> +++ b/utils/gssd/gssd_proc.c
> @@ -133,6 +133,7 @@ read_service_info(char *info_file_name, char **servicename, char **servername,
>  	if ((nbytes = read(fd, buf, INFOBUFLEN)) == -1)
>  		goto fail;
>  	close(fd);
> +	buf[nbytes] = '\0';
>  
>  	numfields = sscanf(buf,"RPC server: %127s\n"
>  		   "service: %127s %15s version %15s\n"

This is not quite right....

We need to expand buf by 1 char in case nbytes == INFOBUFLEN. I'll
respin and resend...

Cheers,
-- 
Jeff Layton <jlayton@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux