]> git.ipfire.org Git - thirdparty/shadow.git/commit
zustr2stp.h: Assert some assumptions about the size
authorAlejandro Colomar <alx@kernel.org>
Thu, 31 Aug 2023 13:36:20 +0000 (15:36 +0200)
committerIker Pedrosa <ikerpedrosam@gmail.com>
Fri, 1 Sep 2023 07:39:23 +0000 (09:39 +0200)
commit9514a841bc90d2a8f6b66768f79c995fe77514f3
tree00d203cf98dcba490be1ed169116b57a2fbf9802
parent3bf8d68f10f2426eda2dd27a21cc0f2a996d5693
zustr2stp.h: Assert some assumptions about the size

If the destination buffer is an array, we can check our assumptions.
This adds a readable way to explain that dsize must be strictly > ssize.
The reason is that the destination string is the source + '\0'.

If the destination is not an array, it's up to _FORTIFY_SOURCE or
-fanalyzer to catch newly introduced errors.  There's nothing we can do;
at least not portably.

Suggested-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/zustr2stp.h