journaling additional fix

This commit is contained in:
SJ 2012-09-28 10:50:00 +02:00
parent 55de53bb26
commit 14ef68ed98
4 changed files with 12 additions and 7 deletions

View File

@ -13,7 +13,7 @@
#define VERSION "0.1.21" #define VERSION "0.1.21"
#define BUILD 708 #define BUILD 709
#define HOSTID "mailarchiver" #define HOSTID "mailarchiver"

View File

@ -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(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); len = write(state.mfd, writebuffer, state.writebufpos);
memset(writebuffer, 0, sizeof(writebuffer)); 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; state->saved_size += len;
//n = write(state->mfd, buf, len); // WRITE //n = write(state->mfd, buf, len); // WRITE
if(len + state->writebufpos > writebuffersize-1){ 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); n = write(state->mfd, writebuffer, state->writebufpos); state->writebufpos = 0; memset(writebuffer, 0, writebuffersize);
} }
memcpy(writebuffer+state->writebufpos, buf, len); state->writebufpos += len; memcpy(writebuffer+state->writebufpos, buf, len); state->writebufpos += len;

View File

@ -34,6 +34,6 @@ char *determine_attachment_type(char *filename, char *type);
char *get_attachment_extractor_by_filename(char *filename); char *get_attachment_extractor_by_filename(char *filename);
void parse_reference(struct _state *state, char *s); void parse_reference(struct _state *state, char *s);
int base64_decode_attachment_buffer(char *p, int plen, unsigned char *b, int blen); 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 */ #endif /* _PARSER_H */

View File

@ -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; char *p;
p = strstr(writebuffer, state->boundaries->s); p = strstr(writebuffer, state->boundaries->s);
if(p){ if(p){
state->writebufpos -= strlen(p); len = strlen(p);
state->writebufpos -= len;
sdata->tot_len -= len;
*p = '\0'; *p = '\0';
p = strrchr(writebuffer, '\n'); p = strrchr(writebuffer, '\n');
if(p){ if(p){
state->writebufpos -= strlen(p); len = strlen(p);
state->writebufpos -= len;
sdata->tot_len -= len;
*p = '\0'; *p = '\0';
} }
} }