Re: [PATCH v2] usb: gadget: ether: Fix MAC address parsing

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

 



On 2015-05-18 14:16, Bjørn Mork wrote:
> Stefan Agner <stefan@xxxxxxxx> writes:
> 
>> MAC addresses can be written without leading zeros. A popular
>> example is libc's ether_ntoa_r function which creates such
>> MAC addresses.
>>
>> Example:
>> 00:14:3d:0f:ff:fe can be written as 0:14:3d:f:ff:fe
>>
>> The function get_ether_addr potentially also parsed past the
>> end of the user provided string. Use the opportunity and fix
>> the function to never parse beyond the end of the string while
>> allowing MAC addresses with and without leading zeros. Also
>> corner cases such as 00:14:3d:0f:ff:0 + new-line character
>> are parsed correctly.
> 
> Please don't allow arbitrary noise in an exported API like this.  It's
> just a recipe for bugs.  Do strict parsing and return clean errors on
> unexpected input.  Don't try to "fix up" anything.  Leave that for
> userspace.

There is not much fix-up beside the allowance of the libc standard
format with single digits and the new-line character.

> 
>>  static int get_ether_addr(const char *str, u8 *dev_addr)
> 
> This function should simply call mac_pton() like the other mac address
> parsers in the kernel.

I agree that using a common implementation makes sense, however that
implementation does not support the central idea of that patch:
supporting the standard format which is created by libc's
ether_ntoa_r...

--
Stefan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux