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]
Message-ID: <fd65c09.2464.16e1fa59f3b.Coremail.liuxiang_1999@126.com>
Date:   Thu, 31 Oct 2019 10:29:38 +0800 (CST)
From:   "Liu Xiang" <liuxiang_1999@....com>
To:     "Rasmus Villemoes" <linux@...musvillemoes.dk>
Cc:     linux-kernel@...r.kernel.org
Subject: Re:Re: [PATCH] lib: string: reduce unnecessary loop in strncpy











At 2019-10-30 22:59:58, "Rasmus Villemoes" <linux@...musvillemoes.dk> wrote:
>On 30/10/2019 15.14, Liu Xiang wrote:
>> Now in strncpy, even src[0] is 0, loop will execute count times until
>> count is 0. It is better to exit the loop immediately when *src is 0.
>
>Please read "man strncpy".
>
>There's a reason the loop is written in that somewhat convoluted way:
>The behavior of strncpy is mandated by the C standard, and if the src
>string is shorter than the destination buffer, the rest must be
>0-filled. So if we hit a nul byte before running out of count, we keep
>copying that nul byte to the rest of the destination.
>
>Rasmus

Hi Rasmus,

Thanks for your explanation. I ignored the C library standard.

Regards

Liu Xiang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ