From 7156b1ef48de59429a3d81d966ef151edc1c01ad Mon Sep 17 00:00:00 2001 From: Nigel Metheringham Date: Wed, 11 Nov 2009 10:08:01 +0000 Subject: [PATCH] Applied signed/unsigned fixes. Need confirmation that this completely deals with bug. Related: #905 --- src/src/dcc.c | 46 +++++++++++++--------------------------------- src/src/dns.c | 4 ++-- src/src/malware.c | 4 ++-- src/src/mime.c | 6 +++--- src/src/receive.c | 7 ++++--- src/src/spf.c | 12 ++++++------ 6 files changed, 30 insertions(+), 49 deletions(-) diff --git a/src/src/dcc.c b/src/src/dcc.c index bfe801787..cc06ed9ce 100644 --- a/src/src/dcc.c +++ b/src/src/dcc.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/dcc.c,v 1.3 2009/10/13 15:08:03 tom Exp $ */ +/* $Cambridge: exim/src/src/dcc.c,v 1.4 2009/11/11 10:08:01 nm4 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -50,16 +50,8 @@ int flushbuffer (int socket, uschar *buffer) int dcc_process(uschar **listptr) { int sep = 0; uschar *list = *listptr; - uschar *user_name; - uschar *body_begin; - uschar user_name_buffer[128]; - unsigned long mbox_size; FILE *data_file; - int dcc_sock; - uschar dcc_buffer[32600]; uschar *dcc_daemon_ip = US""; - int dcc_daemon_port = 6276; - uschar *dcc_request = US"header"; uschar *dcc_default_ip_option = US"127.0.0.1"; uschar *dcc_ip_option = US""; uschar *dcc_helo_option = US"localhost"; @@ -67,7 +59,8 @@ int dcc_process(uschar **listptr) { uschar *xtra_hdrs = NULL; /* from local_scan */ - int i, j, k, c, retval, sockfd, servlen, resp, portnr, line; + int i, j, k, c, retval, sockfd, servlen, resp, line; + unsigned int portnr; struct sockaddr_un serv_addr; struct sockaddr_in serv_addr_in; struct hostent *ipaddress; @@ -82,23 +75,10 @@ int dcc_process(uschar **listptr) { uschar mbox_path[1024]; uschar message_subdir[2]; struct header_line *dcchdr; - struct recipient_item *dcc_rcpt = recipients_list; uschar *dcc_acl_options; uschar dcc_acl_options_buffer[10]; uschar dcc_xtra_hdrs[1024]; - int offset, result; - uschar *p,*q; - int override = 0; - time_t start; - struct sockaddr_un server; -#ifndef NO_POLL_H - struct pollfd pollfd; -#endif - - /* stop compiler warning */ - result = result; - /* grep 1st option */ if ((dcc_acl_options = string_nextinlist(&list, &sep, dcc_acl_options_buffer, @@ -153,7 +133,7 @@ int dcc_process(uschar **listptr) { if (dccifd_address[0] == '/') Ustrncpy(sockpath, dccifd_address, sizeof(sockpath)); else - if( sscanf(CS dccifd_address, "%s %u", sockip, portnr) != 2) { + if( sscanf(CS dccifd_address, "%s %u", sockip, &portnr) != 2) { log_write(0, LOG_MAIN, "dcc acl condition: warning - invalid dccifd address: '%s'", dccifd_address); (void)fclose(data_file); @@ -329,7 +309,7 @@ int dcc_process(uschar **listptr) { Ustrncat(sendbuf, "\n", sizeof(sendbuf)-Ustrlen(sendbuf)-1); flushbuffer(sockfd, sendbuf); DEBUG(D_acl) - debug_printf("\n****************************\n", sendbuf); + debug_printf("\n****************************\n%s", sendbuf); /* Clear the input buffer */ bzero(sendbuf, sizeof(sendbuf)); @@ -380,7 +360,7 @@ int dcc_process(uschar **listptr) { /* Let's read from the socket until there's nothing left to read */ bzero(recvbuf, sizeof(recvbuf)); - while(resp = read(sockfd, recvbuf, sizeof(recvbuf)-1) > 0) { + while((resp = read(sockfd, recvbuf, sizeof(recvbuf)-1)) > 0) { /* How much did we get from the socket */ c = Ustrlen(recvbuf) + 1; DEBUG(D_acl) @@ -405,13 +385,13 @@ int dcc_process(uschar **listptr) { DEBUG(D_acl) debug_printf("Overall result = A\treturning OK\n"); Ustrcpy(dcc_return_text, "Mail accepted by DCC"); - dcc_result = "A"; + dcc_result = US"A"; retval = OK; } else if(recvbuf[i] == 'R') { DEBUG(D_acl) debug_printf("Overall result = R\treturning FAIL\n"); - dcc_result = "R"; + dcc_result = US"R"; retval = FAIL; if(sender_host_name) { log_write(0, LOG_MAIN, "H=%s [%s] F=<%s>: rejected by DCC", sender_host_name, sender_host_address, sender_address); @@ -427,14 +407,14 @@ int dcc_process(uschar **listptr) { Ustrcpy(dcc_return_text, "Not all recipients accepted by DCC"); /* Since we're in an ACL we want a global result * so we accept for all */ - dcc_result = "A"; + dcc_result = US"A"; retval = OK; } else if(recvbuf[i] == 'G') { DEBUG(D_acl) debug_printf("Overall result = G\treturning FAIL\n"); Ustrcpy(dcc_return_text, "Greylisted by DCC"); - dcc_result = "G"; + dcc_result = US"G"; retval = FAIL; } else if(recvbuf[i] == 'T') { @@ -443,7 +423,7 @@ int dcc_process(uschar **listptr) { retval = DEFER; log_write(0,LOG_MAIN,"Temporary error with DCC: %s\n", recvbuf); Ustrcpy(dcc_return_text, "Temporary error with DCC"); - dcc_result = "T"; + dcc_result = US"T"; } else { DEBUG(D_acl) @@ -451,7 +431,7 @@ int dcc_process(uschar **listptr) { retval = DEFER; log_write(0,LOG_MAIN,"Unknown DCC response: %s\n", recvbuf); Ustrcpy(dcc_return_text, "Unknown DCC response"); - dcc_result = "T"; + dcc_result = US"T"; } } else { @@ -517,7 +497,7 @@ int dcc_process(uschar **listptr) { /* check if we should add additional headers passed in acl_m_dcc_add_header */ if(dcc_direct_add_header) { - if (((xtra_hdrs = expand_string("$acl_m_dcc_add_header")) != NULL) && (xtra_hdrs[0] != '\0')) { + if (((xtra_hdrs = expand_string(US"$acl_m_dcc_add_header")) != NULL) && (xtra_hdrs[0] != '\0')) { Ustrncpy(dcc_xtra_hdrs, xtra_hdrs, sizeof(dcc_xtra_hdrs) - 2); if (dcc_xtra_hdrs[Ustrlen(dcc_xtra_hdrs)-1] != '\n') Ustrcat(dcc_xtra_hdrs, "\n"); diff --git a/src/src/dns.c b/src/src/dns.c index d05669c30..9d4da4ae1 100644 --- a/src/src/dns.c +++ b/src/src/dns.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/dns.c,v 1.19 2009/10/19 14:20:58 tom Exp $ */ +/* $Cambridge: exim/src/src/dns.c,v 1.20 2009/11/11 10:08:01 nm4 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -462,8 +462,8 @@ Returns: DNS_SUCCEED successful lookup int dns_basic_lookup(dns_answer *dnsa, uschar *name, int type) { -int rc = -1; #ifndef STAND_ALONE +int rc = -1; uschar *save; #endif diff --git a/src/src/malware.c b/src/src/malware.c index 9b1bd334d..bbd293997 100644 --- a/src/src/malware.c +++ b/src/src/malware.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/malware.c,v 1.17 2009/11/05 19:40:51 nm4 Exp $ */ +/* $Cambridge: exim/src/src/malware.c,v 1.18 2009/11/11 10:08:01 nm4 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -231,7 +231,7 @@ int malware(uschar **listptr) { if ( Ustrstr(buf, US"")) ) { - if (strhelper2 = (Ustrstr(buf, US""))) { + if ((strhelper2 = Ustrstr(buf, US"")) != NULL) { *strhelper2 = '\0'; Ustrcpy(malware_name_buffer, strhelper + 6); } diff --git a/src/src/mime.c b/src/src/mime.c index 7b3ec2580..76783455a 100644 --- a/src/src/mime.c +++ b/src/src/mime.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/mime.c,v 1.18 2009/11/09 14:31:24 tom Exp $ */ +/* $Cambridge: exim/src/src/mime.c,v 1.19 2009/11/11 10:08:02 nm4 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -106,7 +106,7 @@ static int mime_decode_base64(FILE* in, FILE* out, uschar* boundary) opos = obuf; - while (fgets((char *)ibuf, MIME_MAX_LINE_LENGTH, in) != NULL) + while (Ufgets(ibuf, MIME_MAX_LINE_LENGTH, in) != NULL) { if (boundary != NULL && Ustrncmp(ibuf, "--", 2) == 0 @@ -153,7 +153,7 @@ static int mime_decode_base64(FILE* in, FILE* out, uschar* boundary) return -1; /* error */ size += len; /* copy incomplete last byte to start of obuf, where we continue */ - if (bytestate & 3 != 0) + if ((bytestate & 3) != 0) *obuf = *opos; opos = obuf; } diff --git a/src/src/receive.c b/src/src/receive.c index 3c307b07b..47bc10c1e 100644 --- a/src/src/receive.c +++ b/src/src/receive.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/receive.c,v 1.50 2009/10/16 12:33:09 nm4 Exp $ */ +/* $Cambridge: exim/src/src/receive.c,v 1.51 2009/11/11 10:08:02 nm4 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -1067,7 +1067,7 @@ unsigned long mbox_size; header_line *my_headerlist; uschar *user_msg, *log_msg; int mime_part_count_buffer = -1; -int rc; +int rc = OK; memset(CS rfc822_file_path,0,2048); @@ -1285,7 +1285,8 @@ not. */ BOOL receive_msg(BOOL extract_recip) { -int i, rc; +int i; +int rc = FAIL; int msg_size = 0; int process_info_len = Ustrlen(process_info); int error_rc = (error_handling == ERRORS_SENDER)? diff --git a/src/src/spf.c b/src/src/spf.c index 532f81422..ddbb938e4 100644 --- a/src/src/spf.c +++ b/src/src/spf.c @@ -1,4 +1,4 @@ -/* $Cambridge: exim/src/src/spf.c,v 1.8 2008/02/12 12:52:51 nm4 Exp $ */ +/* $Cambridge: exim/src/src/spf.c,v 1.9 2009/11/11 10:08:02 nm4 Exp $ */ /************************************************* * Exim - an Internet mail transport agent * @@ -43,7 +43,7 @@ int spf_init(uschar *spf_helo_domain, uschar *spf_remote_addr) { return 0; } - if (SPF_server_set_rec_dom(spf_server, primary_hostname)) { + if (SPF_server_set_rec_dom(spf_server, CS primary_hostname)) { debug_printf("spf: SPF_server_set_rec_dom() failed.\n"); spf_server = NULL; return 0; @@ -51,14 +51,14 @@ int spf_init(uschar *spf_helo_domain, uschar *spf_remote_addr) { spf_request = SPF_request_new(spf_server); - if (SPF_request_set_ipv4_str(spf_request, spf_remote_addr)) { + if (SPF_request_set_ipv4_str(spf_request, CS spf_remote_addr)) { debug_printf("spf: SPF_request_set_ipv4_str() failed.\n"); spf_server = NULL; spf_request = NULL; return 0; } - if (SPF_request_set_helo_dom(spf_request, spf_helo_domain)) { + if (SPF_request_set_helo_dom(spf_request, CS spf_helo_domain)) { debug_printf("spf: SPF_set_helo_dom() failed.\n"); spf_server = NULL; spf_request = NULL; @@ -86,7 +86,7 @@ int spf_process(uschar **listptr, uschar *spf_envelope_sender, int action) { goto SPF_EVALUATE; }; - if (SPF_request_set_env_from(spf_request, spf_envelope_sender)) { + if (SPF_request_set_env_from(spf_request, CS spf_envelope_sender)) { /* Invalid sender address. This should be a real rare occurence */ rc = SPF_RESULT_PERMERROR; goto SPF_EVALUATE; @@ -94,7 +94,7 @@ int spf_process(uschar **listptr, uschar *spf_envelope_sender, int action) { /* get SPF result */ if (action == SPF_PROCESS_FALLBACK) - SPF_request_query_fallback(spf_request, &spf_response, spf_guess); + SPF_request_query_fallback(spf_request, &spf_response, CS spf_guess); else SPF_request_query_mailfrom(spf_request, &spf_response); -- 2.30.2