<html><head></head><body>I disagree. The size is known. Checking it is going to achieve nothing, as there's nothing sane to do in case of error.<br><br><div class="gmail_quote">Le 8 avril 2020 09:38:14 GMT+03:00, Steve Lhomme <robux4@ycbcr.xyz> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">On 2020-04-08 0:04, Marvin Scholz wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"><hr> include/vlc_strings.h | 12 ++++++++++++<br> src/libvlccore.sym | 1 +<br> src/text/strings.c | 10 ++++++++++<br> 3 files changed, 23 insertions(+)<br><br>diff --git a/include/vlc_strings.h b/include/vlc_strings.h<br>index 411f4a8ceb..e229b32d5d 100644<br>--- a/include/vlc_strings.h<br>+++ b/include/vlc_strings.h<br>@@ -118,6 +118,18 @@ VLC_API void vlc_xml_decode(char *st);<br> */<br> VLC_API char *vlc_xml_encode(const char *str) VLC_MALLOC;<br> <br>+/**<br>+ * Encode binary data as hex string<br>+ *<br>+ * Writes a given data buffer to the output buffer as a null terminated<br>+ * string in hexadecimal representation.<br>+ *<br>+ * \param input Input buffer<br>+ * \param size Input buffer size<br>+ * \param[out] output Output buffer to write the string to<br>+ */<br>+VLC_API void vlc_hex_encode_binary(const void *input, size_t size, char *output);<br>+<br> /**<br> * Base64 encoding.<br> *<br>diff --git a/src/libvlccore.sym b/src/libvlccore.sym<br>index cc8098edd9..17561db932 100644<br>--- a/src/libvlccore.sym<br>+++ b/src/libvlccore.sym<br>@@ -483,6 +483,7 @@ vlc_b64_decode_binary<br> vlc_b64_decode_binary_to_buffer<br> vlc_b64_encode<br> vlc_b64_encode_binary<br>+vlc_hex_encode_binary<br> vlc_cancel<br> vlc_clone<br> VLC_CompileBy<br>diff --git a/src/text/strings.c b/src/text/strings.c<br>index 658249f890..5180f16a83 100644<br>--- a/src/text/strings.c<br>+++ b/src/text/strings.c<br>@@ -346,6 +346,16 @@ char *vlc_xml_encode (const char *str)<br> return stream.ptr;<br> }<br> <br>+/* Hex encoding */<br>+void vlc_hex_encode_binary(const void *input, size_t size, char *output)<br>+{<br>+ unsigned char *buffer = input;<br>+<br>+ for (size_t i = 0; i < size; i++) {<br>+ sprintf(&output[i * 2], "%02" PRIx8, buffer[i]);<br></blockquote><br>You should check the size of the output. Which can be done early in the <br>function.<br><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">+ }<br>+}<br>+<br> /* Base64 encoding */<br> char *vlc_b64_encode_binary(const void *src, size_t length)<br> {<br>-- <br>2.24.1 (Apple Git-126)<hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a><br><br></blockquote><hr>vlc-devel mailing list<br>To unsubscribe or modify your subscription options:<br><a href="https://mailman.videolan.org/listinfo/vlc-devel">https://mailman.videolan.org/listinfo/vlc-devel</a></pre></blockquote></div><br>-- <br>Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.</body></html>