diff --git a/src/config.h b/src/config.h index 964f74ec..717709a8 100644 --- a/src/config.h +++ b/src/config.h @@ -13,7 +13,7 @@ #define VERSION "0.1.23-master-branch" -#define BUILD 776 +#define BUILD 777 #define HOSTID "mailarchiver" diff --git a/src/parser.c b/src/parser.c index beb17ab7..27056580 100644 --- a/src/parser.c +++ b/src/parser.c @@ -218,8 +218,13 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if(state->b64fd != -1){ abuffer[state->abufpos] = '\0'; - n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer)); - n64 = write(state->b64fd, b64buffer, n64); + if(state->base64 == 1){ + n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer)); + n64 = write(state->b64fd, b64buffer, n64); + } + else { + n64 = write(state->b64fd, abuffer, state->abufpos); + } } state->abufpos = 0; memset(abuffer, 0, abuffersize); @@ -245,8 +250,8 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int state->pushed_pointer = 1; - // this is a real attachment to dump - if(state->base64 == 1 && strlen(state->filename) > 4 && strlen(state->type) > 3 && state->n_attachments < MAX_ATTACHMENTS-1){ + // this is a real attachment to dump, it doesn't have to be base64 encoded! + if(strlen(state->filename) > 4 && strlen(state->type) > 3 && state->n_attachments < MAX_ATTACHMENTS-1){ state->n_attachments++; snprintf(state->attachments[state->n_attachments].filename, TINYBUFSIZE-1, "%s", state->filename); @@ -480,8 +485,13 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int if(state->b64fd != -1){ abuffer[state->abufpos] = '\0'; - n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer)); - n64 = write(state->b64fd, b64buffer, n64); + if(state->base64 == 1){ + n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer)); + n64 = write(state->b64fd, b64buffer, n64); + } + else { + n64 = write(state->b64fd, abuffer, state->abufpos); + } } state->abufpos = 0; memset(abuffer, 0, abuffersize);