fixed a journaling bug

This commit is contained in:
SJ 2012-10-01 21:09:11 +02:00
parent ab29175975
commit 6d868c911a
4 changed files with 21 additions and 8 deletions

View File

@ -13,7 +13,7 @@
#define VERSION "0.1.21"
#define BUILD 710
#define BUILD 711
#define HOSTID "mailarchiver"

View File

@ -181,15 +181,23 @@ char *split_str(char *row, char *what, char *s, int size){
* trim trailing CR-LF
*/
void trimBuffer(char *s){
int trimBuffer(char *s){
int n=0;
char *p;
p = strrchr(s, '\n');
if(p) *p = '\0';
if(p){
*p = '\0';
n++;
}
p = strrchr(s, '\r');
if(p) *p = '\0';
if(p){
*p = '\0';
n++;
}
return n;
}

View File

@ -18,7 +18,7 @@ int countCharacterInBuffer(char *p, char c);
void replaceCharacterInBuffer(char *p, char from, char to);
char *split(char *row, int ch, char *s, int size);
char *split_str(char *row, char *what, char *s, int size);
void trimBuffer(char *s);
int trimBuffer(char *s);
int extractEmail(char *rawmail, char *email);
void create_id(char *id);
int get_random_bytes(unsigned char *buf, int len);

View File

@ -157,7 +157,7 @@ void post_parse(struct session_data *sdata, struct _state *state, struct __confi
int parse_line(char *buf, struct _state *state, struct session_data *sdata, int take_into_pieces, char *writebuffer, int writebuffersize, char *abuffer, int abuffersize, struct __config *cfg){
char *p, *q, puf[SMALLBUFSIZE];
unsigned char b64buffer[MAXBUFSIZE];
int x, n, n64, len, writelen, b64_len, boundary_line=0;
int t, x, n, n64, len, writelen, b64_len, boundary_line=0;
if(cfg->debug == 1) printf("line: %s", buf);
@ -312,7 +312,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
}
trimBuffer(buf);
t = trimBuffer(buf);
/* skip the first line, if it's a "From <email address> date" format */
if(state->line_num == 1 && strncmp(buf, "From ", 5) == 0) return 0;
@ -375,7 +375,12 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
sdata->journal_envelope_length -= len;
state->writebufpos = 0; memset(writebuffer, 0, writebuffersize);
memcpy(writebuffer+state->writebufpos, buf, strlen(buf)); state->writebufpos += strlen(buf);
memcpy(writebuffer+state->writebufpos, "\n", 1); state->writebufpos++;
if(t == 2){
memcpy(writebuffer+state->writebufpos, "\r\n", 2); state->writebufpos += 2;
} else {
memcpy(writebuffer+state->writebufpos, "\n", 1); state->writebufpos++;
}
}