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
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 07 Aug 2020 20:42:43 -0700 (PDT)
From:   David Miller <>
Cc:     David.Laight@...LAB.COM,,,,,,
Subject: Re: [PATCH net-next v1] hinic: fix strncpy output truncated
 compile warnings

From: "luobin (L)" <>
Date: Sat, 8 Aug 2020 11:36:42 +0800

> On 2020/8/7 17:32, David Laight wrote:
>>> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>>> b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>>> index c6adc776f3c8..1ec88ebf81d6 100644
>>> --- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>>> +++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
>>> @@ -342,9 +342,9 @@ static int chip_fault_show(struct devlink_fmsg *fmsg,
>>>  	level = event->event.chip.err_level;
>>>  	if (level < FAULT_LEVEL_MAX)
>>> -		strncpy(level_str, fault_level[level], strlen(fault_level[level]));
>>> +		strncpy(level_str, fault_level[level], strlen(fault_level[level]) + 1);
>> Have you even considered what that code is actually doing?
> I'm sorry that I haven't got what you mean and I haven't found any defects in that code. Can you explain more to me?

David is trying to express the same thing I was trying to explain to
you, you should use sizeof(level_str) as the third argument because
the code is trying to make sure that the destination buffer is not

If you use the strlen() of the source buffer, the strncpy() can still
overflow the destination buffer.

Now do you understand?

Powered by blists - more mailing lists