handle zero size Base64 conversions
authorAndreas Steffen <andreas.steffen@strongswan.org>
Mon, 10 Jan 2011 04:06:59 +0000 (05:06 +0100)
committerAndreas Steffen <andreas.steffen@strongswan.org>
Tue, 11 Jan 2011 00:17:40 +0000 (01:17 +0100)
src/libcharon/plugins/tnccs_11/messages/imc_imv_msg.c

index c99cd2e..eafb14e 100644 (file)
@@ -64,6 +64,14 @@ static chunk_t encode_base64(chunk_t data)
        u_char *pos;
        size_t b64_chars, b64_lines;
 
+       /* handle empty message data object */
+       if (data.len == 0)
+       {
+               encoding = chunk_alloc(1);
+               *encoding.ptr = '\0';
+               return encoding;
+       }
+
        /* compute and allocate maximum size of base64 object */
        b64_chars = 4 * ((data.len + 2) / 3);
        b64_lines = (data.len + BYTES_PER_LINE - 1) / BYTES_PER_LINE;