[systemd-devel] usb_id gets bogus serial and makes a mess
Cristian Rodríguez
crrodriguez at opensuse.org
Thu Feb 7 11:32:55 PST 2013
El 07/02/13 11:52, Robert Milasan escribió:
> Hi, seems that using some strange usb devices with really bogus serial
> numbers usb_id creates links with junk strings in it:
>
> Could be added to usb_id and then use it to validated serial_str and
> serial.
>
Something like this is IMHO better
static bool is_valid_usb_id(const char *serial)
{
regex_t preg;
int rc;
if(!serial) return false;
rc = regcomp(&preg, "^[a-zA-Z0-9_-]+$", RULE_REGEX_FLAGS);
if(rc != 0) return false;
if (regexec(&preg, serial, 0, NULL, 0) != 0) {
regfree(&preg);
return false;
}
regfree(&preg);
return true;
}
But.. should the kernel just reject bogus usb ids ??
More information about the systemd-devel
mailing list