]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
kernel: fix wrong strlcat call 23892/head
authorRosen Penev <rosenp@gmail.com>
Sun, 21 Jun 2026 05:02:34 +0000 (22:02 -0700)
committerJonas Jelonek <jelonek.jonas@gmail.com>
Mon, 22 Jun 2026 09:06:48 +0000 (11:06 +0200)
strlcat takes the total buffer size, not the remaining space.
Passing strlen(cmdline) + l caused it to truncate by one byte
when the appended string fit within the buffer.

This is also more consistent with the rest of the file.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/23892
Signed-off-by: Jonas Jelonek <jelonek.jonas@gmail.com>
target/linux/generic/hack-6.12/920-device_tree_cmdline.patch
target/linux/generic/hack-6.18/920-device_tree_cmdline.patch
target/linux/ipq806x/patches-6.12/900-arm-add-cmdline-override.patch
target/linux/mediatek/patches-6.18/901-arm-add-cmdline-override.patch
target/linux/mpc85xx/patches-6.12/102-powerpc-add-cmdline-override.patch
target/linux/mpc85xx/patches-6.18/102-powerpc-add-cmdline-override.patch
target/linux/qualcommax/patches-6.12/0911-arm64-cmdline-replacement.patch

index 4763e82421e537f02132b6beef75b7e055c421fd..2f89dcec70130131316abd437a5622c3e1f64c4b 100644 (file)
@@ -15,7 +15,7 @@ Subject: [PATCH] of/ftd: add device tree cmdline
                strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
 +      p = of_get_flat_dt_prop(node, "bootargs-append", &l);
 +      if (p != NULL && l > 0)
-+              strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE));
++              strlcat(cmdline, p, COMMAND_LINE_SIZE);
  
  handle_cmdline:
        /*
index 8bc6704d4893b05df8014fd137a07459f31c6292..40c42e7bfbdc28df769b68dc89863dd93f213e19 100644 (file)
@@ -15,7 +15,7 @@ Subject: [PATCH] of/ftd: add device tree cmdline
                strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
 +      p = of_get_flat_dt_prop(node, "bootargs-append", &l);
 +      if (p != NULL && l > 0)
-+              strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE));
++              strlcat(cmdline, p, COMMAND_LINE_SIZE);
  
  handle_cmdline:
        /*
index d9e964d018211681aa1ca364c77fffd22dfd3c4a..1e4834527c2b6d9ac7caf8a0009939ba8abec0db 100644 (file)
@@ -19,7 +19,7 @@
 +++ b/drivers/of/fdt.c
 @@ -1053,6 +1053,17 @@ int __init early_init_dt_scan_chosen(cha
        if (p != NULL && l > 0)
-               strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE));
+               strlcat(cmdline, p, COMMAND_LINE_SIZE);
  
 +    /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different
 +     * device tree option of chosen/bootargs-override. This is
index d1a4376bed0e2759794500d896610eeb96cf7d2e..ebc4fb8b72a182b2ae590921e0d419a18570efa0 100644 (file)
@@ -33,7 +33,7 @@ Signed-off-by: Yoonji Park <koreapyj@dcmys.kr>
 +++ b/drivers/of/fdt.c
 @@ -1120,6 +1120,17 @@ int __init early_init_dt_scan_chosen(cha
        if (p != NULL && l > 0)
-               strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE));
+               strlcat(cmdline, p, COMMAND_LINE_SIZE);
  
 +    /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different
 +     * device tree option of chosen/bootargs-override. This is
index 2e526d6a30b9b2f663497b4707396d83acb8c8b9..bdd45edfacae33ed2e98a7e092034503884593dd 100644 (file)
@@ -19,7 +19,7 @@
 +++ b/drivers/of/fdt.c
 @@ -1053,6 +1053,17 @@ int __init early_init_dt_scan_chosen(cha
        if (p != NULL && l > 0)
-               strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE));
+               strlcat(cmdline, p, COMMAND_LINE_SIZE);
  
 +    /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different
 +     * device tree option of chosen/bootargs-override. This is
index 6479766765b2a7c4864f179b11d43c32b14c28cd..f2ea1febb7976269697850cad4efab6588a0fbb8 100644 (file)
@@ -19,7 +19,7 @@
 +++ b/drivers/of/fdt.c
 @@ -1120,6 +1120,17 @@ int __init early_init_dt_scan_chosen(cha
        if (p != NULL && l > 0)
-               strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE));
+               strlcat(cmdline, p, COMMAND_LINE_SIZE);
  
 +    /* CONFIG_CMDLINE_OVERRIDE is used to fallback to a different
 +     * device tree option of chosen/bootargs-override. This is
index b376265a5cebb2090887537bf7bb718c713a6fff..127677d2200e4bd3a8b76c97bca831d4eeb78b34 100644 (file)
@@ -102,4 +102,4 @@ Signed-off-by: Qiyuan Zhang <zhang.github@outlook.com>
 +
        p = of_get_flat_dt_prop(node, "bootargs-append", &l);
        if (p != NULL && l > 0)
-               strlcat(cmdline, p, min_t(int, strlen(cmdline) + (int)l, COMMAND_LINE_SIZE));
+               strlcat(cmdline, p, COMMAND_LINE_SIZE);