summaryrefslogtreecommitdiff
path: root/board/amlogic
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>2023-07-14 13:24:50 +0200
committerTom Rini <trini@konsulko.com>2023-08-08 17:05:43 -0400
commit615828721abfe8c73b5103d4436402ecbf9b9897 (patch)
treebdd4cb11ef01155c17dfa51115eeff976bba05e7 /board/amlogic
parenta169438411f9277cc689c14078151aa1d1caae3c (diff)
downloadu-boot-615828721abfe8c73b5103d4436402ecbf9b9897.tar.gz
u-boot-615828721abfe8c73b5103d4436402ecbf9b9897.tar.bz2
u-boot-615828721abfe8c73b5103d4436402ecbf9b9897.zip
Revert "lib: string: Fix strlcpy return value", fix callers
Both the Linux kernel and libbsd agree that strlcpy() should always return strlen(src) and not include the NUL termination. The incorrect U-Boot implementation makes it impossible to check the return value for truncation, and breaks code written with the usual implementation in mind (for example, fdtdec_add_reserved_memory() was subtly broken). I reviewed all callers of strlcpy() and strlcat() and fixed them according to my understanding of the intended function. This reverts commit d3358ecc54be0bc3b4dd11f7a63eab0a2842f772 and adds related fixes. Fixes: d3358ecc54be ("lib: string: Fix strlcpy return value") Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Sean Anderson <sean.anderson@seco.com>
Diffstat (limited to 'board/amlogic')
-rw-r--r--board/amlogic/vim3/vim3.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c
index fcd60ab1e0..8bdfb302f7 100644
--- a/board/amlogic/vim3/vim3.c
+++ b/board/amlogic/vim3/vim3.c
@@ -104,8 +104,8 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd)
}
/* Update PHY names (mandatory to disable USB3.0) */
- len = strlcpy(data, "usb2-phy0", 32);
- len += strlcpy(&data[len], "usb2-phy1", 32 - len);
+ len = strlcpy(data, "usb2-phy0", 32) + 1;
+ len += strlcpy(&data[len], "usb2-phy1", 32 - len) + 1;
ret = fdt_setprop(blob, node, "phy-names", data, len);
if (ret < 0) {
printf("vim3: failed to update usb phy names property (%d)\n", ret);
@@ -132,7 +132,7 @@ int meson_ft_board_setup(void *blob, struct bd_info *bd)
}
/* Enable PCIe */
- len = strlcpy(data, "okay", 32);
+ len = strlcpy(data, "okay", 32) + 1;
ret = fdt_setprop(blob, node, "status", data, len);
if (ret < 0) {
printf("vim3: failed to enable pcie node (%d)\n", ret);