diff --git a/src/config.h b/src/config.h index 5c4a0bc..acb54c0 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 57be1d1..8c88059 100644 --- a/src/parser.c +++ b/src/parser.c @@ -84,7 +84,7 @@ } 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 @@ 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 c0f24b4..2363472 100644 --- a/src/parser.h +++ b/src/parser.h @@ -34,6 +34,6 @@ 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 179a867..b85d1ca 100644 --- a/src/parser_utils.c +++ b/src/parser_utils.c @@ -813,16 +813,21 @@ } -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'; } }