]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev-builtin-net_id: fix potential buffer overflow 28619/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 28 Sep 2022 09:09:29 +0000 (18:09 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 1 Aug 2023 12:34:12 +0000 (21:34 +0900)
src/udev/udev-builtin-net_id.c

index 4936ba518a07540d0b795b62b023b7d771824e71..d1f343573da35be9384ba2851957a63bbedfe066 100644 (file)
@@ -948,11 +948,11 @@ static int names_usb(sd_device *dev, NetNames *names) {
 
         /* append USB config number, suppress the common config == 1 */
         if (!streq(config, "1"))
-                l = strpcpyl(&s, sizeof(names->usb_ports), "c", config, NULL);
+                l = strpcpyl(&s, l, "c", config, NULL);
 
         /* append USB interface number, suppress the interface == 0 */
         if (!streq(interf, "0"))
-                l = strpcpyl(&s, sizeof(names->usb_ports), "i", interf, NULL);
+                l = strpcpyl(&s, l, "i", interf, NULL);
         if (l == 0)
                 return log_device_debug_errno(dev, SYNTHETIC_ERRNO(ENAMETOOLONG),
                                               "Generated USB name would be too long.");