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 PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 11 Aug 2021 09:40:34 +0200 From: Robert Richter <rric@...nel.org> To: Joe Perches <joe@...ches.com> Cc: Len Baker <len.baker@....com>, Borislav Petkov <bp@...en8.de>, Mauro Carvalho Chehab <mchehab@...nel.org>, Tony Luck <tony.luck@...el.com>, James Morse <james.morse@....com>, Kees Cook <keescook@...omium.org>, linux-hardening@...r.kernel.org, linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org Subject: Re: [PATCH v3] drivers/edac/edac_mc: Remove all strcpy() uses On 10.08.21 08:02:17, Joe Perches wrote: > On Tue, 2021-08-10 at 16:36 +0200, Robert Richter wrote: > > On 09.08.21 10:18:58, Joe Perches wrote: > > > > > strscpy and scnprintf have different return values and it's simpler > > > and much more common to use scnprintf for appended strings that are > > > limited to a specific buffer length. > > > > Calculating the bytes written from the return value is a oneliner. > > Not really. > You still have to test for strscpy's possible return of -E2BIG. I thought of: num = strscpy(p, OTHER_LABEL, len); num = num < 0 ? len : num; len -= num; p += num; Clearly, this does not look nice, esp. if this is repeated in the code. That's why I prefer the strlen(p) implementation: strscpy(p, OTHER_LABEL, len); len -= strlen(p); p += strlen(p); -Robert
Powered by blists - more mailing lists