lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Sun, 14 Sep 2014 18:13:11 +0200
From:	Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To:	Karsten Keil <isdn@...ux-pingi.de>,
	Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
Cc:	Network Development <netdev@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] isdn: act2000: capi.c: Cleaning up unnecessary use of
 memset in conjunction with strncpy

2014-09-14 18:01 GMT+02:00 Rickard Strandqvist
<rickard_strandqvist@...ctrumdigital.se>:
> Using memset before strncpy just to ensure a trailing null
> character is an unnecessary double writing of a string
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
> ---
>  drivers/isdn/act2000/capi.c |    8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/isdn/act2000/capi.c b/drivers/isdn/act2000/capi.c
> index 3f66ca2..1267739 100644
> --- a/drivers/isdn/act2000/capi.c
> +++ b/drivers/isdn/act2000/capi.c
> @@ -907,10 +907,10 @@ actcapi_dispatch(struct work_struct *work)
>                 case 0xff02:
>                         /* MANUFACTURER_IND */
>                         if (msg->msg.manuf_msg == 3) {
> -                               memset(tmp, 0, sizeof(tmp));
>                                 strncpy(tmp,
>                                         &msg->msg.manufacturer_ind_err.errstring,
> -                                       msg->hdr.len - 16);
> +                                       sizeof(tmp));
> +                               tmp[sizeof(tmp) - 1] = '\0';
>                                 if (msg->msg.manufacturer_ind_err.errcode)
>                                         printk(KERN_WARNING "act2000: %s\n", tmp);
>                                 else {
> @@ -1136,9 +1136,9 @@ actcapi_debug_msg(struct sk_buff *skb, int direction)
>                                msg->msg.manufacturer_ind_err.controller);
>                         printk(KERN_DEBUG " Code = 0x%08x\n",
>                                msg->msg.manufacturer_ind_err.errcode);
> -                       memset(tmp, 0, sizeof(tmp));
>                         strncpy(tmp, &msg->msg.manufacturer_ind_err.errstring,
> -                               msg->hdr.len - 16);
> +                               sizeof(tmp));
> +                       tmp[sizeof(tmp) - 1] = '\0';
>                         printk(KERN_DEBUG " Emsg = '%s'\n", tmp);
>                         break;
>                 }
> --
> 1.7.10.4
>

Hi

I'm sorry, this will not give the same effect :-(
Please, ignore this patch!

Kind regards
Rickard Strandqvist
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists