]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-5436 --resolve
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 22 May 2013 00:39:02 +0000 (19:39 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 22 May 2013 00:39:21 +0000 (19:39 -0500)
src/switch_utils.c

index 2141369c62a5d1d4fe3859f229e3a476b817ba89..146e34d6fc1b07df0650d5e89fc39b4a7a02ba33 100644 (file)
@@ -666,6 +666,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;
                        }
@@ -678,11 +681,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;
 }