]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commit
sysfsutils: fix my_strncat function
authorHongxu Jia <hongxu.jia@windriver.com>
Wed, 4 Jun 2025 08:17:44 +0000 (16:17 +0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 12 Jun 2025 13:22:55 +0000 (14:22 +0100)
commita5d2a5ce94b82957e2a9336c18dce9b28073cd71
treec98a6ad0379dfbe7fb16033f711cc9f03a9bc6ea
parentc064ef18343a956aea397d36d2e7665d6c8afd7d
sysfsutils: fix my_strncat function

The bug was introduced by upstream commit [1] where strncat was replaced with
internal my_strncat function, such as:

  char dest[32] = "/sys/devices/platform/axi";
  my_strncat(dest, "/", sizeof(dest) - strlen(dest) - 1);

Will result in dest string being:

  /sys/

and not the expected:

  /sys/devices/platform/axi/

The meaning of the "len" parameter in the my_strncat function is the size limit for
copying characters from "from", not the size limit for "to" after copying. Also,
the "#define safestrcat(to, from) my_strncat(to, from, sizeof(to) - strlen(to) - 1)"
has already imposed a limit on max based on the size of "to". Modify the function
to prevent truncation of content when too many bytes are passed to the my_strcat function.

[1] https://github.com/linux-ras/sysfsutils/commit/0719881cad85f837f039ecb378b823306640902a

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
meta/recipes-core/sysfsutils/files/0001-Modify-my_strncat-function.patch [new file with mode: 0644]
meta/recipes-core/sysfsutils/sysfsutils_2.1.1.bb