Code cleanup

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2020-03-03 15:47:02 +01:00
parent ee7f5d970b
commit d687fa16ab
33 changed files with 32 additions and 66 deletions

View File

@ -305,5 +305,3 @@ int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct c
return 0;
}

View File

@ -169,5 +169,3 @@ CLOSE:
return attachments;
}

View File

@ -71,9 +71,8 @@ void base64_encode(unsigned char *in, int inlen, char *out, int outlen){
}
buf[i] = *(in+j);
i++;
i++;
}
base64_encode_block(buf, i, &out[pos]);
}

View File

@ -78,7 +78,7 @@ void process_bdat(struct smtp_session *session, char *readbuf, int readlen, stru
else syslog(LOG_PRIORITY, "ERROR: write(), %s, %d, %s", __func__, __LINE__, __FILE__);
}
if(session->bdat_bytes_to_read < 0){
// malformed data from client: we got more data then had been told in BDAT argument
syslog(LOG_PRIORITY, "ERROR: invalid BDAT data. Expected %d, got %d bytes", session->bdat_bytes_to_read + readlen, readlen);

View File

@ -148,7 +148,7 @@ int parse_config_file(char *configfile, struct config *target_cfg, struct _parse
printf("failed to parse %s: \"%s\"\n", line, chpos+1);
}
break;
}
}
i++;
}
@ -230,7 +230,7 @@ void print_config_item(struct config *cfg, struct _parse_rule *rules, int i){
trimBuffer(p);
printf("%s=%s\n", rules[i].name, p);
}
}
@ -297,12 +297,10 @@ void print_config(char *configfile, struct config *cfg){
i++;
}
if(!rules[i].name) printf("unknown key: \"%s\" \n", line);
}
}
fclose(f);
}

View File

@ -41,7 +41,7 @@ int clamd_scan(char *tmpfile, struct config *cfg){
/* issue the SCAN command with full path to the temporary directory */
memset(scan_cmd, 0, SMALLBUFSIZE);
snprintf(scan_cmd, SMALLBUFSIZE-1, "SCAN %s/%s\r\n", cfg->workdir, tmpfile);

View File

@ -136,4 +136,3 @@
#define S_STATUS_ERROR "error"
#endif /* _CONFIG_H */

View File

@ -74,7 +74,7 @@ void update_counters(struct session_data *sdata, struct data *data, struct count
if(counters->c_stored_size > 0) memcached_increment(&(data->memc), MEMCACHED_MSGS_STORED_SIZE, counters->c_stored_size, &mc);
bzero(&c, sizeof(c));
bzero(&c, sizeof(c));
snprintf(buf, MAXBUFSIZE-1, "%s %s %s %s %s %s %s", MEMCACHED_MSGS_RCVD, MEMCACHED_MSGS_VIRUS, MEMCACHED_MSGS_DUPLICATE, MEMCACHED_MSGS_IGNORE, MEMCACHED_MSGS_SIZE, MEMCACHED_MSGS_STORED_SIZE, MEMCACHED_COUNTERS_LAST_UPDATE);
@ -94,7 +94,7 @@ void update_counters(struct session_data *sdata, struct data *data, struct count
snprintf(buf, SMALLBUFSIZE-1, "%ld", sdata->now); memcached_add(&(data->memc), "set", MEMCACHED_COUNTERS_LAST_UPDATE, buf, strlen(buf), 0, 0);
snprintf(buf, SMALLBUFSIZE-1, "UPDATE `%s` SET `rcvd`=%llu, `virus`=%llu, `duplicate`=%llu, `ignore`=%llu, `size`=%llu, `stored_size`=%llu", SQL_COUNTER_TABLE, c.c_rcvd, c.c_virus, c.c_duplicate, c.c_ignore, c.c_size, c.c_stored_size);
//if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: update counters: %s", sdata->ttmpfile, buf);
p_query(sdata, buf);

View File

@ -133,4 +133,3 @@ void digest_string(char *s, char *digest){
snprintf(digest + i*2, 2*DIGEST_LENGTH, "%02x", md[i]);
}

View File

@ -317,5 +317,3 @@ void extract_attachment_content(struct session_data *sdata, struct parser_state
}

View File

@ -163,4 +163,3 @@ unsigned int DJBHash(char* str, unsigned int len){
return hash;
}

View File

@ -285,4 +285,3 @@ struct mi htmlentities[] = {
#endif /* _HTMLENTITIES_H */

View File

@ -363,7 +363,7 @@ int process_imap_folder(char *folder, struct session_data *sdata, struct data *d
void send_imap_close(struct data *data){
char puf[SMALLBUFSIZE];
char puf[SMALLBUFSIZE];
snprintf(puf, sizeof(puf)-1, "A%d CLOSE\r\n", data->import->seq);
write1(data->net, puf, strlen(puf));
@ -447,7 +447,7 @@ int list_folders(struct data *data){
q++;
fldrlen = strtol(q, NULL, 10);
} else {
if(fldrlen) {
ruf = malloc(strlen(q) * 2 + 1);
memset(ruf, 0, strlen(q) * 2 + 1);

View File

@ -65,7 +65,7 @@ int import_message(struct session_data *sdata, struct data *data, struct config
data->import->total_size += sdata->tot_len;
sdata->delivered = 0;
sdata->import = 1;
@ -124,7 +124,7 @@ int import_message(struct session_data *sdata, struct data *data, struct config
default:
printf("failed to import: %s (id: %s)\n", data->import->filename, sdata->ttmpfile);
break;
}
}
if(rc != OK && data->import->failed_folder){
p = strrchr(data->import->filename, '/');

View File

@ -23,4 +23,3 @@ int process_imap_folder(char *folder, struct session_data *sdata, struct data *d
void send_imap_close(struct data *data);
#endif /* _IMPORT_H */

View File

@ -92,6 +92,3 @@ void free_list(struct list *list){
p = q;
}
}

View File

@ -14,4 +14,3 @@ int is_item_on_string(struct list *list, char *s);
void free_list(struct list *list);
#endif /* _LIST_H */

View File

@ -197,7 +197,7 @@ int memcached_connect(struct memcached_server *ptr){
{
(void)close(ptr->fd);
ptr->fd= -1;
}
return MEMCACHED_FAILURE;
@ -299,7 +299,7 @@ char *memcached_get(struct memcached_server *ptr, char *key, unsigned int *len,
*flags = atoi(p+1);
*p = '\0';
p = strchr(ptr->result, '\r');
if(!p) return NULL;
@ -372,5 +372,3 @@ char *memcached_fetch_result(struct memcached_server *ptr, char *key, char *valu
return p;
}

View File

@ -410,28 +410,28 @@ int ssl_want_retry(SSL *ssl, int ret, int timeout){
i = SSL_get_error(ssl, ret);
if(i == SSL_ERROR_NONE)
return 1;
tv.tv_sec = timeout/1000;
tv.tv_usec = 0;
FD_ZERO(&fds);
switch(i){
case SSL_ERROR_WANT_READ: // pause until the socket is readable
sock = SSL_get_rfd(ssl);
FD_SET(sock, &fds);
i = select(sock+1, &fds, 0, 0, &tv);
break;
case SSL_ERROR_WANT_WRITE: // pause until the socket is writeable
sock = SSL_get_wfd(ssl);
FD_SET(sock, &fds);
i = select(sock+1, 0, &fds, 0, &tv);
break;
case SSL_ERROR_ZERO_RETURN: // the sock closed, just return quietly
i = 0;
break;
default: // ERROR - unexpected error code
i = -1;
break;

View File

@ -104,7 +104,6 @@ int p_exec_stmt(struct session_data *sdata, struct sql *sql){
bind[i].buffer = sql->sql[i];
bind[i].is_null = 0;
}
else { break; }
}
@ -222,7 +221,7 @@ int prepare_sql_statement(struct session_data *sdata, struct sql *sql, char *s){
return ERR;
}
return OK;
return OK;
}

View File

@ -259,7 +259,7 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata
p = get_attachment_extractor_by_filename(state->attachments[state->n_attachments].filename);
snprintf(state->attachments[state->n_attachments].shorttype, TINYBUFSIZE-1, "%s", p);
if(strcmp("other", p)){
state->b64fd = open(state->attachments[state->n_attachments].aname, O_CREAT|O_RDWR, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
state->attachments[state->n_attachments].dumped = 1;
@ -590,7 +590,7 @@ int parse_line(char *buf, struct parser_state *state, struct session_data *sdata
state->message_state = MSG_UNDEF;
return 0;
return 0;
}
if(boundary_line == 1){ return 0; }

View File

@ -246,7 +246,7 @@ time_t parse_date_header(char *datestr){
} else {
tm.tm_min = atoi(r);
}
continue;
continue;
}
}
@ -518,13 +518,13 @@ void markHTML(char *buf, struct parser_state *state){
}
if(state->htmltag == 1){
if(j == 0 && *s == '!'){
state->skip_html = 1;
//printf("skiphtml=1\n");
}
if(state->skip_html == 0){
if(state->skip_html == 0){
if(*s != '>' && *s != '<' && *s != '"'){
//printf("j=%d/%c", j, *s);
html[j] = tolower(*s);
@ -973,7 +973,7 @@ char *determine_attachment_type(char *filename, char *type){
if(strncasecmp(p, "jpg", 3) == 0) return "image,";
if(strncasecmp(p, "jpeg", 4) == 0) return "image,";
if(strncasecmp(p, "tiff", 4) == 0) return "image,";
}
}
}
return "other,";
@ -1055,4 +1055,3 @@ void fix_plus_sign_in_email_address(char *puf, char **at_sign, unsigned int *len
*at_sign = r;
}
}

View File

@ -57,5 +57,3 @@ int main(int argc, char **argv){
return 0;
}

View File

@ -41,7 +41,7 @@ int main(int argc, char **argv){
break;
default :
default :
break;
}
}

View File

@ -508,7 +508,7 @@ int main(int argc, char **argv){
rc = append_email_to_buffer(&fromdomain, optarg);
break;
break;
case 'R' :
@ -519,8 +519,8 @@ int main(int argc, char **argv){
rc = append_email_to_buffer(&todomain, optarg);
break;
break;
case 'a' :
startdate = convert_time(optarg, 0, 0, 0);
break;
@ -604,5 +604,3 @@ int main(int argc, char **argv){
return 0;
}

View File

@ -54,5 +54,3 @@ int main(int argc, char **argv){
return 0;
}

View File

@ -271,7 +271,7 @@ int main(int argc, char **argv){
break;
default :
default :
break;
}
}

View File

@ -21,4 +21,3 @@ void initrules(struct node *xhash[]);
void clearrules(struct node *xhash[]);
#endif /* _RULES_H */

View File

@ -56,4 +56,3 @@ signal_func *set_signal_handler(int signo, signal_func * func){
return oact.sa_handler;
}

View File

@ -64,4 +64,3 @@
// LMTP responses
#define LMTP_RESP_220_BANNER "220 %s LMTP\r\n"

View File

@ -235,5 +235,3 @@ int remove_stored_message_files(struct session_data *sdata, struct parser_state
return 0;
}

View File

@ -26,4 +26,3 @@ void taia_now(struct taia *t);
void taia_pack(char *s, struct taia *t);
#endif /* _TAI_H */

View File

@ -163,7 +163,7 @@ int main(int argc, char **argv){
printf("hdr len: %d\n", sdata.hdr_len);
rule = check_against_ruleset(data.archiving_rules, &state, st.st_size, sdata.spam_message);
printf("body digest: %s\n", sdata.bodydigest);
printf("rules check: %s\n", rule);