This function is intended to be like snprintf() where the output is
simply truncated if the output buffer isn't big enough.  However,
there are some significant bugs that cause the function to write past
the end of the output buffer if it isn't big enough, so document it
this way.
---
 lib/util/stringutils.h | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/lib/util/stringutils.h b/lib/util/stringutils.h
index 61030b3..c059c77 100644
--- a/lib/util/stringutils.h
+++ b/lib/util/stringutils.h
@@ -141,8 +141,25 @@ int expand_by_doubling(
  * @brief Replace questionable chars from string for printing.
  *
  * @note Caller handles memory for dst.
- * @note Output might be truncated, compared to input.
  * @note dst will be null terminated, at or before index dst_sz-1.
+ *
+ * @param[out] dst
+ *     Location of the buffer to hold the output string.  This must
+ *     not be NULL.
+ * @param[in] src
+ *     The input string to escape.  This must not be NULL.
+ * @param[in] dst_sz
+ *     Size of the buffer at @p dst.  The buffer must be big enough to
+ *     hold the entire escaped string, including the nul terminator.
+ * @param[out] dst_len_out
+ *     On return, the value at this location will be set to the length
+ *     of the escaped string (excluding the nul terminator).  This
+ *     parameter may be NULL.
+ * @param[in] other_chars_to_escape
+ *     nul-terminated array of additional characters to escape with a
+ *     backslash.  This must not be NULL.
+ *
+ * @return dst
 
------------------------------------------------------------------------------*/
 char *scrub_for_print(
     char *dst,
-- 
2.4.3


------------------------------------------------------------------------------
_______________________________________________
rpstir-devel mailing list
rpstir-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpstir-devel

Reply via email to