udev: use strndupa_safe() rather than strndupa()

As per coding style, we don't use strndupa(), but strndupa_safe() only.

As a side-effect, this means musl folks can just drop this mess:

https://git.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd/0003-src-basic-missing.h-check-for-missing-strndupa.patch
This commit is contained in:
Lennart Poettering
2024-03-06 13:23:17 +00:00
committed by Luca Boccassi
parent da95494ca3
commit 10d50d9eac
+6 -6
View File
@@ -731,15 +731,15 @@ static int names_platform(sd_device *dev, const char *prefix, bool test) {
* The Vendor (3 or 4 char), followed by hexadecimal model number : instance id. */
if (r == 10 && p[7] == ':') {
/* 3 char vendor string */
vendor = strndupa(p, 3);
model_str = strndupa(p + 3, 4);
instance_str = strndupa(p + 8, 2);
vendor = strndupa_safe(p, 3);
model_str = strndupa_safe(p + 3, 4);
instance_str = strndupa_safe(p + 8, 2);
validchars = UPPERCASE_LETTERS;
} else if (r == 11 && p[8] == ':') {
/* 4 char vendor string */
vendor = strndupa(p, 4);
model_str = strndupa(p + 4, 4);
instance_str = strndupa(p + 9, 2);
vendor = strndupa_safe(p, 4);
model_str = strndupa_safe(p + 4, 4);
instance_str = strndupa_safe(p + 9, 2);
validchars = UPPERCASE_LETTERS DIGITS;
} else
return -EOPNOTSUPP;