mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-26 04:20:11 +01:00
fixed a journaling bug
This commit is contained in:
parent
ab29175975
commit
6d868c911a
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#define VERSION "0.1.21"
|
#define VERSION "0.1.21"
|
||||||
|
|
||||||
#define BUILD 710
|
#define BUILD 711
|
||||||
|
|
||||||
#define HOSTID "mailarchiver"
|
#define HOSTID "mailarchiver"
|
||||||
|
|
||||||
|
14
src/misc.c
14
src/misc.c
@ -181,15 +181,23 @@ char *split_str(char *row, char *what, char *s, int size){
|
|||||||
* trim trailing CR-LF
|
* trim trailing CR-LF
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void trimBuffer(char *s){
|
int trimBuffer(char *s){
|
||||||
|
int n=0;
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
p = strrchr(s, '\n');
|
p = strrchr(s, '\n');
|
||||||
if(p) *p = '\0';
|
if(p){
|
||||||
|
*p = '\0';
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
p = strrchr(s, '\r');
|
p = strrchr(s, '\r');
|
||||||
if(p) *p = '\0';
|
if(p){
|
||||||
|
*p = '\0';
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ int countCharacterInBuffer(char *p, char c);
|
|||||||
void replaceCharacterInBuffer(char *p, char from, char to);
|
void replaceCharacterInBuffer(char *p, char from, char to);
|
||||||
char *split(char *row, int ch, char *s, int size);
|
char *split(char *row, int ch, char *s, int size);
|
||||||
char *split_str(char *row, char *what, 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);
|
int extractEmail(char *rawmail, char *email);
|
||||||
void create_id(char *id);
|
void create_id(char *id);
|
||||||
int get_random_bytes(unsigned char *buf, int len);
|
int get_random_bytes(unsigned char *buf, int len);
|
||||||
|
@ -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){
|
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];
|
char *p, *q, puf[SMALLBUFSIZE];
|
||||||
unsigned char b64buffer[MAXBUFSIZE];
|
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);
|
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 */
|
/* 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;
|
if(state->line_num == 1 && strncmp(buf, "From ", 5) == 0) return 0;
|
||||||
@ -375,9 +375,14 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
|
|||||||
sdata->journal_envelope_length -= len;
|
sdata->journal_envelope_length -= len;
|
||||||
state->writebufpos = 0; memset(writebuffer, 0, writebuffersize);
|
state->writebufpos = 0; memset(writebuffer, 0, writebuffersize);
|
||||||
memcpy(writebuffer+state->writebufpos, buf, strlen(buf)); state->writebufpos += strlen(buf);
|
memcpy(writebuffer+state->writebufpos, buf, strlen(buf)); state->writebufpos += strlen(buf);
|
||||||
|
if(t == 2){
|
||||||
|
memcpy(writebuffer+state->writebufpos, "\r\n", 2); state->writebufpos += 2;
|
||||||
|
} else {
|
||||||
memcpy(writebuffer+state->writebufpos, "\n", 1); state->writebufpos++;
|
memcpy(writebuffer+state->writebufpos, "\n", 1); state->writebufpos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(state->is_1st_header == 1 && state->message_state == MSG_REFERENCES){
|
if(state->is_1st_header == 1 && state->message_state == MSG_REFERENCES){
|
||||||
if(strncasecmp(buf, "References:", 11) == 0) parse_reference(state, buf+11);
|
if(strncasecmp(buf, "References:", 11) == 0) parse_reference(state, buf+11);
|
||||||
|
Loading…
Reference in New Issue
Block a user