[PATCH] fs: cifs: cifsencrypt.c: Cleaning up missing null-terminate in conjunction with strncpy

Joe Perches joe at perches.com
Sat Aug 2 18:27:46 MDT 2014


On Sun, 2014-08-03 at 01:13 +0200, Rickard Strandqvist wrote:
> 2014-08-02 19:33 GMT+02:00 Joe Perches <joe at perches.com>:
> > On Sat, 2014-08-02 at 11:55 -0500, Shirish Pargaonkar wrote:
> >> Acked-by: Shirish Pargaonkar <spargaonkar at suse.com>
> > []
> >> > diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
> > []
> >> > @@ -307,7 +307,7 @@ int calc_lanman_hash(const char *password, const char *cryptkey, bool encrypt,
> >> >
> >> >         memset(password_with_pad, 0, CIFS_ENCPWD_SIZE);
> >> >         if (password)
> >> > -               strncpy(password_with_pad, password, CIFS_ENCPWD_SIZE);
> >> > +               strncpy(password_with_pad, password, CIFS_ENCPWD_SIZE - 1);
> >
> >
> > Is this always correct?
[]
> Because password_with_pad gets set to all zeros above, the character,
> I do not guarantee a copy terminating null.
> Unless it is so that you do not want any terminating null.

That's the question for Steve and cifs people.



More information about the samba-technical mailing list