diff --git a/src/misc.c b/src/misc.c index 5e43fb2c..8cc0bbd1 100644 --- a/src/misc.c +++ b/src/misc.c @@ -195,6 +195,8 @@ void trimBuffer(char *s){ int extractEmail(char *rawmail, char *email){ char *p; + memset(email, 0, SMALLBUFSIZE); + p = strchr(rawmail, '<'); if(p){ snprintf(email, SMALLBUFSIZE-1, "%s", p+1); diff --git a/src/parser.c b/src/parser.c index d7b5add1..aa218c31 100644 --- a/src/parser.c +++ b/src/parser.c @@ -18,7 +18,8 @@ struct _state parse_message(struct session_data *sdata, int take_into_pieces, struct __config *cfg){ FILE *f; - char buf[MAXBUFSIZE]; + int i, len; + char *p, buf[MAXBUFSIZE], puf[SMALLBUFSIZE]; struct _state state; init_state(&state); @@ -30,6 +31,42 @@ struct _state parse_message(struct session_data *sdata, int take_into_pieces, st } + if(sdata->num_of_rcpt_to > 0){ + for(i=0; inum_of_rcpt_to; i++){ + extractEmail(sdata->rcptto[i], puf); + + if(strlen(puf) > 5){ + p = strstr(puf, cfg->hostid); + if(p && *(p-1) == '.'){ + + *(p-1) = ' '; + *p = '\0'; + + len = strlen(puf); + + if(does_it_seem_like_an_email_address(puf) == 1){ + + if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: processing rcpt to address: *%s*", sdata->ttmpfile, puf); + + if(strlen(state.b_to) < MAXBUFSIZE-len-1){ + if(is_string_on_list(state.rcpt, puf) == 0){ + append_list(&(state.rcpt), puf); + memcpy(&(state.b_to[strlen(state.b_to)]), puf, len); + + if(strlen(state.b_to) < MAXBUFSIZE-len-1){ + split_email_address(puf); + memcpy(&(state.b_to[strlen(state.b_to)]), puf, len); + } + } + } + + } + } + } + + } + } + if(take_into_pieces == 1){ state.mfd = open(sdata->tmpframe, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR); if(state.mfd == -1){