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: <d5f4164f-7cee-3fdb-49ce-4e1d1d70572a@embeddedor.com>
Date:   Tue, 15 Oct 2019 14:26:47 -0500
From:   "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To:     ayman.bagabas@...il.com, Darren Hart <dvhart@...radead.org>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] platform/x86: huawei-wmi: Fix misuse of strcmp() function

Hi Ayman,

On 10/15/19 14:08, ayman.bagabas@...il.com wrote:

>>  	/* Huawei laptops come with one battery only */
>> -	if (strcmp(battery->desc->name, "BAT") != 1)
> 
> Note we don't have a battery number in BATx, strcmp would return 1 if
> battery->desc->name is "BAT0" or any one digit. This is a desired
> behavior where some Huawei laptops identify the first battery as "BAT1"
> and this would match if name is greater than "BAT" by one digit.
> 

Great to know this is not a bug. I don't think there is any
other instance in the whole codebase like this one: strcmp(...) != 1
So, that's an odd thing to see...  Maybe you can consider adding
the whole description above as a code comment? :)

> Maybe strcmp(battery->desc->name, "BAT") < 0 is a better way to go.
> 

Yeah; this is bit more specific.

Thanks!
--
Gustavo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ