[rtmpdump] [PATCH] Make sure base 64 encoded string is null-terminated when using GnuTLS to encode

Isaac Schemm isaacschemm at gmail.com
Thu Jan 12 19:55:15 EET 2017


---
 librtmp/rtmp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
index a2863b0..511822e 100644
--- a/librtmp/rtmp.c
+++ b/librtmp/rtmp.c
@@ -2451,8 +2451,11 @@ b64enc(const unsigned char *input, int length,
char *output, int maxsize)
       return 0;
     }
 #elif defined(USE_GNUTLS)
-  if (BASE64_ENCODE_RAW_LENGTH(length) <= maxsize)
-    base64_encode_raw((uint8_t*) output, length, input);
+  if (BASE64_ENCODE_RAW_LENGTH(length) < maxsize)
+    {
+      base64_encode_raw((uint8_t*) output, length, input);
+      output[BASE64_ENCODE_RAW_LENGTH(length)] = '\0';
+    }
   else
     {
       RTMP_Log(RTMP_LOGDEBUG, "%s, error", __FUNCTION__);

--
2.8.1.windows.1


More information about the rtmpdump mailing list