digest fixes

This commit is contained in:
SJ 2011-12-09 15:24:15 +01:00
parent 64dd86e169
commit b58ff0886b
3 changed files with 18 additions and 14 deletions

View File

@ -15,8 +15,8 @@
int make_body_digest(struct session_data *sdata, struct __config *cfg){
int i=0, n, fd, hdr_len=0, offset=3;
char *body=NULL;
int i=0, n, fd, offset=3;
char *p, *body=NULL;
unsigned char buf[BIGBUFSIZE], md[DIGEST_LENGTH];
SHA256_CTX context;
@ -29,25 +29,27 @@ int make_body_digest(struct session_data *sdata, struct __config *cfg){
if(fd == -1) return -1;
while((n = read(fd, buf, sizeof(buf))) > 0){
body = (char *)&buf[0];
if(i == 0){
hdr_len = searchStringInBuffer(body, sizeof(buf), "\n\r\n", 3);
if(hdr_len == 0){
searchStringInBuffer(body, sizeof(buf), "\n\n", 2);
p = strstr(body, "\n\r\n");
if(!p){
p = strstr(body, "\n\n");
if(p){
offset = 2;
}
}
if(hdr_len > 0){
hdr_len += offset;
if(p){
sdata->hdr_len = p - body + offset;
body += sdata->hdr_len;
sdata->hdr_len = hdr_len;
n -= sdata->hdr_len;
body += hdr_len;
n -= hdr_len;
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: hdr_len: %d, offset: %d", sdata->ttmpfile, hdr_len, offset);
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: hdr_len: %d, offset: %d", sdata->ttmpfile, sdata->hdr_len, offset);
}
}

View File

@ -468,7 +468,8 @@ void translateLine(unsigned char *p, struct _state *state){
if(delimiter_characters[(unsigned int)*p] != ' ')
*p = ' ';
else {
*p = tolower(*p);
// commented out because it breaks utf-8 encoding, 2011.12.07.
//*p = tolower(*p);
}
}

View File

@ -54,6 +54,7 @@ void handle_smtp_session(int new_sd, struct __data *data, struct __config *cfg){
if(mysql_real_connect(&(sdata.mysql), cfg->mysqlhost, cfg->mysqluser, cfg->mysqlpwd, cfg->mysqldb, cfg->mysqlport, cfg->mysqlsocket, 0)){
db_conn = 1;
mysql_real_query(&(sdata.mysql), "SET NAMES utf8", strlen("SET NAMES utf8"));
mysql_real_query(&(sdata.mysql), "SET CHARACTER SET utf8", strlen("SET CHARACTER SET utf8"));
}
else
syslog(LOG_PRIORITY, "%s", ERR_MYSQL_CONNECT);