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. > 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. Bjørn -- 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