Krzysztof Opasiak <k.opasiak@xxxxxxxxxxx> writes: > On 05/18/2015 04:18 PM, Stefan Agner wrote: > >> Krzysztof, beside the two digit format, I don't see a really problematic >> constraint which would be added by switching to mac_pton. A MAC address >> with the newline character would still be valid (echo case). >> > > Nope, mac_pton() accepts only strlen(s) < 3 * ETH_ALEN - 1 strings > what means that we need to have \0 right after last character of MAC > address. Before calling this function we have to replace \n with \0 > what requires to strdup() the buffer as it is const. I think you misread that part. mac_pton() requires that strlen(s) is at least 3 * ETH_ALEN - 1, but it does allow it to be longer. It does not check anything following the mac address. It is up to the caller to implement additional restrictions like only allowing \0 or \n after the mac address. See netconsole for an example: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/netconsole.c#n477 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