From isaacschemm at gmail.com Thu Jan 12 19:55:15 2017 From: isaacschemm at gmail.com (Isaac Schemm) Date: Thu, 12 Jan 2017 11:55:15 -0600 Subject: [rtmpdump] [PATCH] Make sure base 64 encoded string is null-terminated when using GnuTLS to encode Message-ID: --- 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