mirror of
https://github.com/sailfishos/ofono
synced 2025-12-08 02:32:37 +08:00
udev: Check for valid USB serial numbers
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <libudev.h>
|
||||
|
||||
@@ -86,8 +87,14 @@ static const char *get_serial(struct udev_device *udev_device)
|
||||
entry = udev_list_entry_get_next(entry);
|
||||
}
|
||||
|
||||
if (serial && strpbrk(serial, ".-_?*") != NULL)
|
||||
return NULL;
|
||||
if (serial != NULL) {
|
||||
unsigned int i, len = strlen(serial);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!isalnum(serial[i]))
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return serial;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user