From ec26a78f1ea87682b59322f4703761a12aa12471 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Sat, 20 Jun 2026 22:02:34 -0700 Subject: [PATCH] kernel: fix wrong strlcat call 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 Link: https://github.com/openwrt/openwrt/pull/23892 Signed-off-by: Jonas Jelonek --- target/linux/generic/hack-6.12/920-device_tree_cmdline.patch | 2 +- target/linux/generic/hack-6.18/920-device_tree_cmdline.patch | 2 +- .../ipq806x/patches-6.12/900-arm-add-cmdline-override.patch | 2 +- .../mediatek/patches-6.18/901-arm-add-cmdline-override.patch | 2 +- .../mpc85xx/patches-6.12/102-powerpc-add-cmdline-override.patch | 2 +- .../mpc85xx/patches-6.18/102-powerpc-add-cmdline-override.patch | 2 +- .../patches-6.12/0911-arm64-cmdline-replacement.patch | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/target/linux/generic/hack-6.12/920-device_tree_cmdline.patch b/target/linux/generic/hack-6.12/920-device_tree_cmdline.patch index 4763e82421e..2f89dcec701 100644 --- a/target/linux/generic/hack-6.12/920-device_tree_cmdline.patch +++ b/target/linux/generic/hack-6.12/920-device_tree_cmdline.patch @@ -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: /* diff --git a/target/linux/generic/hack-6.18/920-device_tree_cmdline.patch b/target/linux/generic/hack-6.18/920-device_tree_cmdline.patch index 8bc6704d489..40c42e7bfbd 100644 --- a/target/linux/generic/hack-6.18/920-device_tree_cmdline.patch +++ b/target/linux/generic/hack-6.18/920-device_tree_cmdline.patch @@ -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: /* diff --git a/target/linux/ipq806x/patches-6.12/900-arm-add-cmdline-override.patch b/target/linux/ipq806x/patches-6.12/900-arm-add-cmdline-override.patch index d9e964d0182..1e4834527c2 100644 --- a/target/linux/ipq806x/patches-6.12/900-arm-add-cmdline-override.patch +++ b/target/linux/ipq806x/patches-6.12/900-arm-add-cmdline-override.patch @@ -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 diff --git a/target/linux/mediatek/patches-6.18/901-arm-add-cmdline-override.patch b/target/linux/mediatek/patches-6.18/901-arm-add-cmdline-override.patch index d1a4376bed0..ebc4fb8b72a 100644 --- a/target/linux/mediatek/patches-6.18/901-arm-add-cmdline-override.patch +++ b/target/linux/mediatek/patches-6.18/901-arm-add-cmdline-override.patch @@ -33,7 +33,7 @@ Signed-off-by: Yoonji Park +++ 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 diff --git a/target/linux/mpc85xx/patches-6.12/102-powerpc-add-cmdline-override.patch b/target/linux/mpc85xx/patches-6.12/102-powerpc-add-cmdline-override.patch index 2e526d6a30b..bdd45edfaca 100644 --- a/target/linux/mpc85xx/patches-6.12/102-powerpc-add-cmdline-override.patch +++ b/target/linux/mpc85xx/patches-6.12/102-powerpc-add-cmdline-override.patch @@ -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 diff --git a/target/linux/mpc85xx/patches-6.18/102-powerpc-add-cmdline-override.patch b/target/linux/mpc85xx/patches-6.18/102-powerpc-add-cmdline-override.patch index 6479766765b..f2ea1febb79 100644 --- a/target/linux/mpc85xx/patches-6.18/102-powerpc-add-cmdline-override.patch +++ b/target/linux/mpc85xx/patches-6.18/102-powerpc-add-cmdline-override.patch @@ -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 diff --git a/target/linux/qualcommax/patches-6.12/0911-arm64-cmdline-replacement.patch b/target/linux/qualcommax/patches-6.12/0911-arm64-cmdline-replacement.patch index b376265a5ce..127677d2200 100644 --- a/target/linux/qualcommax/patches-6.12/0911-arm64-cmdline-replacement.patch +++ b/target/linux/qualcommax/patches-6.12/0911-arm64-cmdline-replacement.patch @@ -102,4 +102,4 @@ Signed-off-by: Qiyuan Zhang + 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); -- 2.47.3