Subject: Re: [PATCH net-next] bonding: fix strlen errors in sysfs

From: Jay Vosburgh <[email-masked]>
Date: Thu, 14 Jul 2011 09:02:06 -0700

Vitalii Demianets <[email-masked]> wrote:

>On Thursday 14 July 2011 04:57:45 Andy Gospodarek wrote:
>> -			if (strnicmp
>> -			    (slave->dev->name, buf,
>> -			     strlen(slave->dev->name)) == 0) {
>> +			int max_len = max(strlen(slave->dev->name),
>> +					  strlen(buf) - 1);
>> +			if (strnicmp(slave->dev->name, buf, max_len) == 0) {
>
>As for me there is no sense in preventing "address out of range" errors in  
>strnicmp by calculating length with strlen first. If there is missing \0 at 
>the end of the string you just shift failure point from stricmp to the strlen 
>function call.
>IMHO "maximum length" argument in strnicmp should be some appropriate constant 
>instead. Alternatively we can use count:

	I agree about using a constant, and I nominate IFNAMSIZ for that
constant.

	Also, should we really be using strnicmp?  I.e., case
insensitive?  Aren't interface names case sensitive?

	-J

---
	-Jay Vosburgh, IBM Linux Technology Center, [email-masked]