diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-25 23:33:42 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-27 22:18:14 +0200 |
commit | 55e35a4d59bea8653a428f544490b1d80b848d64 (patch) | |
tree | b9763cd0ce350b6f597e00d97d7a821f384be2c6 /src | |
parent | sd-device: make sd_device_get_devtype() return 0 on success again (diff) | |
download | systemd-55e35a4d59bea8653a428f544490b1d80b848d64.tar.xz systemd-55e35a4d59bea8653a428f544490b1d80b848d64.zip |
sd-device: refuse earlier when too long ifname is passed to sd_device_new_from_ifname()
Otherwise, alloca() called in strjoina() may trigger assertion.
This partially reverts 3652891c3904992e21739e9bfb004073841db63c.
The commit mistakenly dropped the check.
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-device/sd-device.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c index dafda626f0..3d683fb280 100644 --- a/src/libsystemd/sd-device/sd-device.c +++ b/src/libsystemd/sd-device/sd-device.c @@ -345,9 +345,11 @@ _public_ int sd_device_new_from_ifname(sd_device **ret, const char *ifname) { assert_return(ret, -EINVAL); assert_return(ifname, -EINVAL); - r = device_new_from_main_ifname(ret, ifname); - if (r >= 0) - return r; + if (ifname_valid(ifname)) { + r = device_new_from_main_ifname(ret, ifname); + if (r >= 0) + return r; + } r = rtnl_resolve_ifname_full(NULL, RESOLVE_IFNAME_ALTERNATIVE | RESOLVE_IFNAME_NUMERIC, ifname, &main_name, NULL); if (r < 0) |