[PATCH] s4-libcli: Fix comparsion of uninitalized bytes.

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Jul 2 06:36:12 MDT 2013


On Tue, Jul 02, 2013 at 12:23:48PM +0200, Andreas Schneider wrote:
> Found by valgrind.
> 
> Signed-off-by: Andreas Schneider <asn at samba.org>
> ---
>  source4/libcli/clireadwrite.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/source4/libcli/clireadwrite.c b/source4/libcli/clireadwrite.c
> index 7d8f34a..7d73e75 100644
> --- a/source4/libcli/clireadwrite.c
> +++ b/source4/libcli/clireadwrite.c
> @@ -38,6 +38,8 @@ ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, void *_buf, off_t offset
>  		return 0;
>  	}
>  
> +	memset(buf, 0, size);
> +
>  	parms.readx.level = RAW_READ_READX;
>  	parms.readx.in.file.fnum = fnum;

To be honest, I don't understand why this should be
necessary. I thought the idea of the smbcli_read call would
be to download something from the server and fill it into
"_buf". This would make the memory initialized. Why does
valgrind require to first initialize something that we
overwrite later anyway?

Don't get me wrong. I am not against fixing a valgrind bug.
I just want to understand this.

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list