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  linux-hardening  linux-cve-announce  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:   Wed, 18 Oct 2023 13:22:06 +0300
From:   Dan Carpenter <dan.carpenter@...aro.org>
To:     Calvince Otieno <calvncce@...il.com>
Cc:     gustavo@...eddedor.com, outreachy@...ts.linux.dev,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Martyn Welch <martyn@...chs.me.uk>,
        Manohar Vanga <manohar.vanga@...il.com>,
        linux-kernel@...r.kernel.org, linux-staging@...ts.linux.dev,
        Julia Lawall <julia.lawall@...ia.fr>
Subject: Re: [PATCH V2] staging: vme_user: replace strcpy with strscpy

On Wed, Oct 18, 2023 at 11:53:00AM +0300, Calvince Otieno wrote:
> Checkpatch suggests using strscpy() instead of strcpy().
> 
> The advantages of strscpy() are that it always adds a NUL terminator
> and prevents read overflows if the source string is not properly
> terminated.

strcpy() also always adds a NUL terminator.

With strcpy() both read overflows and write overflows are an issue but
write overflows are sooooooo much more serious that we don't worry about
read overflow.

> One potential disadvantage is that it doesn't zero pad the
> string like strcpy() does.

strcpy() does not zero pad anything.  You're resending patches too
quickly.  You should wait a day between resends.


> 
> In this specific context, both strscpy and strcpy performs the same
> operation without any functional difference.
> 
> The reason for this equivalence is that the driver_name string "vme_fake"
> is shorter than the size of the fake_bridge->name array which is defined
> as 16 characters (struct vme_bridge {char name[VMENAMSIZ];...}). Thus,
> there is no risk of buffer overflow in either case. VMENAMSIZ variable
> holds a constant value of 16 (#define VMENAMSIZ 16)

This paragraph is good and sufficient.

> 
> The null-terminated "vme_fake" string
> (static const char driver_name[] = "vme_fake";) can be safely copied into
> fake_bridge->name using either strscpy or strcpy.
> 
> While using strscpy() does not address any bugs, it is considered a better
> practice and aligns with checkpatch recommendations.
> 
> Signed-off-by: Calvince Otieno <calvncce@...il.com>


Okay.  Good.  Re-write the commit message and resend it tomorrow.

regards,
dan carpenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ