From 14ef68ed98277addd21e90fbcc58385319c82e8f Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 28 Sep 2012 10:50:00 +0200 Subject: [PATCH] journaling additional fix --- src/config.h | 2 +- src/parser.c | 4 ++-- src/parser.h | 2 +- src/parser_utils.c | 11 ++++++++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/config.h b/src/config.h index 5c4a0bc1..acb54c0e 100644 --- a/src/config.h +++ b/src/config.h @@ -13,7 +13,7 @@ #define VERSION "0.1.21" -#define BUILD 708 +#define BUILD 709 #define HOSTID "mailarchiver" diff --git a/src/parser.c b/src/parser.c index 57be1d1f..8c880594 100644 --- a/src/parser.c +++ b/src/parser.c @@ -84,7 +84,7 @@ struct _state parse_message(struct session_data *sdata, int take_into_pieces, st } if(take_into_pieces == 1 && state.writebufpos > 0){ - if(state.ms_journal == 1) remove_trailing_journal_boundary(&writebuffer[0], &state); + if(state.ms_journal == 1) remove_trailing_journal_boundary(sdata, &state, &writebuffer[0]); len = write(state.mfd, writebuffer, state.writebufpos); memset(writebuffer, 0, sizeof(writebuffer)); @@ -214,7 +214,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int state->saved_size += len; //n = write(state->mfd, buf, len); // WRITE if(len + state->writebufpos > writebuffersize-1){ - if(state->ms_journal == 1) remove_trailing_journal_boundary(writebuffer, state); + if(state->ms_journal == 1) remove_trailing_journal_boundary(sdata, state, writebuffer); n = write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize); } memcpy(writebuffer+state->writebufpos, buf, len); state->writebufpos += len; diff --git a/src/parser.h b/src/parser.h index c0f24b46..23634729 100644 --- a/src/parser.h +++ b/src/parser.h @@ -34,6 +34,6 @@ char *determine_attachment_type(char *filename, char *type); char *get_attachment_extractor_by_filename(char *filename); void parse_reference(struct _state *state, char *s); int base64_decode_attachment_buffer(char *p, int plen, unsigned char *b, int blen); -void remove_trailing_journal_boundary(char *writebuffer, struct _state *state); +void remove_trailing_journal_boundary(struct session_data *sdata, struct _state *state, char *writebuffer); #endif /* _PARSER_H */ diff --git a/src/parser_utils.c b/src/parser_utils.c index 179a8670..b85d1ca2 100644 --- a/src/parser_utils.c +++ b/src/parser_utils.c @@ -813,16 +813,21 @@ int base64_decode_attachment_buffer(char *p, int plen, unsigned char *b, int ble } -void remove_trailing_journal_boundary(char *writebuffer, struct _state *state){ +void remove_trailing_journal_boundary(struct session_data *sdata, struct _state *state, char *writebuffer){ + int len; char *p; p = strstr(writebuffer, state->boundaries->s); if(p){ - state->writebufpos -= strlen(p); + len = strlen(p); + state->writebufpos -= len; + sdata->tot_len -= len; *p = '\0'; p = strrchr(writebuffer, '\n'); if(p){ - state->writebufpos -= strlen(p); + len = strlen(p); + state->writebufpos -= len; + sdata->tot_len -= len; *p = '\0'; } }