All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/4] Misc fixes for strlcpy() and strlcat()
@ 2024-02-18 19:51 Rodrigo Campos
  2024-02-18 19:51 ` [PATCH v3 1/4] tools/nolibc/string: export strlen() Rodrigo Campos
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Rodrigo Campos @ 2024-02-18 19:51 UTC (permalink / raw)
  To: Willy Tarreau, Thomas Weißschuh; +Cc: linux-kernel, Rodrigo Campos

As requested by Willy and Thomas[1], here go some more fixes and tests for
strlcpy() and strlcat().

The first patch just fixes the compilation when the compiler might replace some
code with its strlen() implementation, which will not be found. Therefore, we
just export it as that can happen also on user-code, outside of nolibc.

The rest of the commits:
	* Fix the return code of both functions
	* Make sure to always null-terminate the dst buffer
	* Honor the size parameter as documented
	* Add tests for both functions

All has been checked against the corresponding libbsd implementation[2].

Let me know what you think 🙂

---
Changes from v2:
 * Add v3 to the subject, previously I wasn't using v<revision>
 * Make strlcat() and strlcpy() have a shorter size when compiled
 * Make src and dst buffer sizes different in test and add trailing chars, so we
   can easily detect more bugs.

[1]: https://lore.kernel.org/all/9538a8fe-b92f-42a5-99d1-25969cf51647@sdfg.com.ar/
[2]: https://gitlab.freedesktop.org/libbsd/libbsd.git


Rodrigo Campos (4):
  tools/nolibc/string: export strlen()
  tools/nolibc: Fix strlcat() return code and size usage
  tools/nolibc: Fix strlcpy() return code and size usage
  selftests/nolibc: Add tests for strlcat() and strlcpy()

 tools/include/nolibc/string.h                | 47 ++++++++++++--------
 tools/testing/selftests/nolibc/nolibc-test.c | 40 +++++++++++++++++
 2 files changed, 69 insertions(+), 18 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-04-26 16:45 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-18 19:51 [PATCH v3 0/4] Misc fixes for strlcpy() and strlcat() Rodrigo Campos
2024-02-18 19:51 ` [PATCH v3 1/4] tools/nolibc/string: export strlen() Rodrigo Campos
2024-02-18 19:51 ` [PATCH v3 2/4] tools/nolibc: Fix strlcat() return code and size usage Rodrigo Campos
2024-02-18 19:51 ` [PATCH v3 3/4] tools/nolibc: Fix strlcpy() " Rodrigo Campos
2024-02-18 19:51 ` [PATCH v3 4/4] selftests/nolibc: Add tests for strlcat() and strlcpy() Rodrigo Campos
2024-02-18 20:39   ` Rodrigo Campos
2024-02-18 21:11     ` Willy Tarreau
2024-02-18 21:41       ` Rodrigo Campos
2024-04-23  9:18   ` Thomas Weißschuh
2024-04-23 16:28     ` Willy Tarreau
2024-04-23 19:49       ` Paul E. McKenney
2024-04-26 16:43     ` Rodrigo Campos
2024-02-19 20:48 ` [PATCH v3 0/4] Misc fixes for strlcpy() and strlcat() Willy Tarreau
2024-02-20 19:25   ` Rodrigo Campos

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.