lkml.org 
[lkml]   [2014]   [Aug]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] fs: cifs: cifsencrypt.c: Cleaning up missing null-terminate in conjunction with strncpy
From
Acked-by: Shirish Pargaonkar <spargaonkar@suse.com>

On Sat, Jul 26, 2014 at 5:28 PM, Rickard Strandqvist
<rickard_strandqvist@spectrumdigital.se> wrote:
> If you are going to use memset before strncpy you must copy sizeof -1
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> fs/cifs/cifsencrypt.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
> index 4934347..dcca8b3 100644
> --- 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);
>
> if (!encrypt && global_secflags & CIFSSEC_MAY_PLNTXT) {
> memcpy(lnm_session_key, password_with_pad,
> --
> 1.7.10.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html


\
 
 \ /
  Last update: 2014-08-02 19:21    [W:0.060 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site