diff --git a/src/protocol/data.c b/src/protocol/data.c index 42dea5aa..eca79896 100644 --- a/src/protocol/data.c +++ b/src/protocol/data.c @@ -118,6 +118,7 @@ data_protocol_handler(struct connection *conn) struct cache_entry *cached = get_cache_entry(uri); unsigned char *data_start, *data; int base64 = 0; + int datalen = 0; if (!cached) { abort_connection(conn, connection_state(S_OUT_OF_MEM)); @@ -141,7 +142,7 @@ data_protocol_handler(struct connection *conn) } if (base64) { - unsigned char *decoded = base64_encode(data); + unsigned char *decoded = base64_decode_bin(data, strlen(data), &datalen); if (!decoded) { abort_connection(conn, connection_state(S_OUT_OF_MEM)); @@ -155,7 +156,7 @@ data_protocol_handler(struct connection *conn) { /* Use strlen() to get the correct decoded length */ - int datalen = strlen(data); + if (!datalen) datalen = strlen(data); add_fragment(cached, conn->from, data, datalen); conn->from += datalen; diff --git a/src/util/base64.c b/src/util/base64.c index 8046cc9c..7fafa208 100644 --- a/src/util/base64.c +++ b/src/util/base64.c @@ -63,9 +63,9 @@ base64_encode_bin(register unsigned char *in, int inlen, int *outlen) return outstr; } -/* Base64 decoding is used only with the CONFIG_FORMHIST or CONFIG_GSSAPI +/* Base64 decoding is used only with the CONFIG_FORMHIST, CONFIG_GSSAPI or CONFIG_DATA feature, so i'll #ifdef it */ -#if defined(CONFIG_FORMHIST) || defined(CONFIG_GSSAPI) +#if defined(CONFIG_FORMHIST) || defined(CONFIG_GSSAPI) || defined(CONFIG_DATA) unsigned char * base64_decode(register unsigned char *in)