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:	Tue, 5 Aug 2014 22:40:06 +0200
From:	Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To:	Chris Metcalf <cmetcalf@...era.com>
Cc:	Wang Sheng-Hui <shhuiw@...il.com>,
	Daniel Walter <dwalter@...gle.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] arch: tile: kernel: setup.c: Cleaning up missing
 null-terminate in conjunction with strncpy

2014-08-05 22:12 GMT+02:00 Chris Metcalf <cmetcalf@...era.com>:
> On 7/26/2014 10:04 AM, Rickard Strandqvist wrote:
>>
>> Replacing strncpy with strlcpy to avoid strings that lacks null terminate.
>>
>> Signed-off-by: Rickard Strandqvist
>> <rickard_strandqvist@...ctrumdigital.se>
>> ---
>>   arch/tile/kernel/setup.c |    2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/tile/kernel/setup.c b/arch/tile/kernel/setup.c
>> index 112abab..1af7d19 100644
>> --- a/arch/tile/kernel/setup.c
>> +++ b/arch/tile/kernel/setup.c
>> @@ -1087,7 +1087,7 @@ static int __init setup_initramfs_file(char *str)
>>   {
>>         if (str == NULL)
>>                 return -EINVAL;
>> -       strncpy(initramfs_file, str, sizeof(initramfs_file) - 1);
>> +       strlcpy(initramfs_file, str, sizeof(initramfs_file));
>>         set_initramfs_file = 1;
>>         return 0;
>
>
> I'm inclined not to take this change, because it's not necessary.
> The initramfs_file[] is already zero-filled by being in the BSS, and
> this is a pretty obscure boot option, so it seems a bit more
> maintainable to use a somewhat more standard string API call.
>


Hi

Of course this is quite alright, the goal is to create code that it
can not get any bugs.
With sizeof -1 will get it right, if you can only be sure that the
zeroes string will be overwritten.


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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ