sd-device: drop unwanted newline in netlink message
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 16 Nov 2020 15:51:14 +0000 (00:51 +0900)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Dec 2020 17:08:31 +0000 (18:08 +0100)
(cherry picked from commit b9cbb08e0a35070d57721cd5bf810659a0b80f5e)

src/libsystemd/sd-device/device-private.c

index 1e61732dfe6d15caf9c5be196d21518153b8f1f3..beff6f4e25eaffcbb29c8c51dfd28944c5f708e8 100644 (file)
@@ -468,6 +468,10 @@ int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len) {
 
                 i += end - key + 1;
 
+                /* netlink messages for some devices contain an unwanted newline at the end of value.
+                 * Let's drop the newline and remaining characters after the newline. */
+                truncate_nl(key);
+
                 r = device_append(device, key, &major, &minor);
                 if (r < 0)
                         return r;