Re: [PATCH 1/8] ACPI sysfs.c strlen fix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 30 Jun 2012, Len Brown wrote:

> From: Pavel Vasilyev <pavel@xxxxxxxxxxx>
> 
> Current code is ignoring the last character of "enable" and "disable"
> in comparisons.
> 
> https://bugzilla.kernel.org/show_bug.cgi?id=33732
> 
> Signed-off-by: Len Brown <len.brown@xxxxxxxxx>
> ---
>  drivers/acpi/sysfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
> index 9f66181..240a244 100644
> --- a/drivers/acpi/sysfs.c
> +++ b/drivers/acpi/sysfs.c
> @@ -173,7 +173,7 @@ static int param_set_trace_state(const char *val, struct kernel_param *kp)
>  {
>  	int result = 0;
>  
> -	if (!strncmp(val, "enable", strlen("enable") - 1)) {
> +	if (!strncmp(val, "enable", strlen("enable"))) {

Ironically, this is the less efficient of two possible fixes.

It would have been better to leave the "- 1" in place and change strlen 
to sizeof.  That's probably what the original author had in mind.

Alan Stern



[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux