From: Anthony Minessale Date: Wed, 22 May 2013 00:39:02 +0000 (-0500) Subject: FS-5436 --resolve X-Git-Tag: v1.5.1~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a3b69a4a67d397fbbc7231a85c3e35bbc8ab433;p=thirdparty%2Ffreeswitch.git FS-5436 --resolve --- diff --git a/src/switch_utils.c b/src/switch_utils.c index 7cec27e204..3efe68d456 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -677,6 +677,9 @@ SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size while (l >= 6) { out[bytes++] = switch_b64_table[(b >> (l -= 6)) % 64]; + if (bytes >= olen - 1) { + goto end; + } if (++y != 72) { continue; } @@ -689,11 +692,15 @@ SWITCH_DECLARE(switch_status_t) switch_b64_encode(unsigned char *in, switch_size out[bytes++] = switch_b64_table[((b % 16) << (6 - l)) % 64]; } if (l != 0) { - while (l < 6) { + while (l < 6 && bytes < olen - 1) { out[bytes++] = '=', l += 2; } } + end: + + out[bytes] = '\0'; + return SWITCH_STATUS_SUCCESS; }