From: Lennart Poettering Date: Wed, 6 Mar 2024 08:45:55 +0000 (+0100) Subject: udev: use strndupa_safe() rather than strndupa() X-Git-Tag: v256-rc1~627 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=10d50d9eac0ed94576928a23e3fa525ddc49c2aa;p=systemd%2F.git 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 --- diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 2482436006..8ef3abada9 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -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;