fixed attachment handling

This commit is contained in:
SJ 2013-03-23 17:58:58 +01:00
parent 0d59e95bd8
commit 31d801da6f
2 changed files with 17 additions and 7 deletions

View File

@ -13,7 +13,7 @@
#define VERSION "0.1.23-master-branch" #define VERSION "0.1.23-master-branch"
#define BUILD 776 #define BUILD 777
#define HOSTID "mailarchiver" #define HOSTID "mailarchiver"

View File

@ -218,9 +218,14 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
if(state->b64fd != -1){ if(state->b64fd != -1){
abuffer[state->abufpos] = '\0'; abuffer[state->abufpos] = '\0';
if(state->base64 == 1){
n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer)); n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer));
n64 = write(state->b64fd, b64buffer, n64); n64 = write(state->b64fd, b64buffer, n64);
} }
else {
n64 = write(state->b64fd, abuffer, state->abufpos);
}
}
state->abufpos = 0; memset(abuffer, 0, abuffersize); 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; state->pushed_pointer = 1;
// this is a real attachment to dump // this is a real attachment to dump, it doesn't have to be base64 encoded!
if(state->base64 == 1 && strlen(state->filename) > 4 && strlen(state->type) > 3 && state->n_attachments < MAX_ATTACHMENTS-1){ if(strlen(state->filename) > 4 && strlen(state->type) > 3 && state->n_attachments < MAX_ATTACHMENTS-1){
state->n_attachments++; state->n_attachments++;
snprintf(state->attachments[state->n_attachments].filename, TINYBUFSIZE-1, "%s", state->filename); snprintf(state->attachments[state->n_attachments].filename, TINYBUFSIZE-1, "%s", state->filename);
@ -480,9 +485,14 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
if(state->b64fd != -1){ if(state->b64fd != -1){
abuffer[state->abufpos] = '\0'; abuffer[state->abufpos] = '\0';
if(state->base64 == 1){
n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer)); n64 = base64_decode_attachment_buffer(abuffer, state->abufpos, &b64buffer[0], sizeof(b64buffer));
n64 = write(state->b64fd, b64buffer, n64); n64 = write(state->b64fd, b64buffer, n64);
} }
else {
n64 = write(state->b64fd, abuffer, state->abufpos);
}
}
state->abufpos = 0; memset(abuffer, 0, abuffersize); state->abufpos = 0; memset(abuffer, 0, abuffersize);
} }