-/* $Cambridge: exim/src/src/spam.c,v 1.18 2010/06/05 11:13:30 pdp Exp $ */
-
/*************************************************
* Exim - an Internet mail transport agent *
*************************************************/
int spam_rc = 0;
uschar *prev_spamd_address_work = NULL;
-int spam(uschar **listptr) {
+int
+spam(uschar **listptr)
+{
int sep = 0;
uschar *list = *listptr;
uschar *user_name;
uschar user_name_buffer[128];
unsigned long mbox_size;
FILE *mbox_file;
- int spamd_sock;
+ int spamd_sock = -1;
uschar spamd_buffer[32600];
int i, j, offset, result;
uschar spamd_version[8];
(spamd_address_container *)store_get(sizeof(spamd_address_container));
/* grok spamd address and port */
- if( sscanf(CS address, "%s %u", this_spamd->tcp_addr, &(this_spamd->tcp_port)) != 2 ) {
+ if (sscanf(CS address, "%23s %u", this_spamd->tcp_addr, &(this_spamd->tcp_port)) != 2)
+ {
log_write(0, LOG_MAIN,
"spam acl condition: warning - invalid spamd address: '%s'", address);
continue;
}
+ if (spamd_sock == -1) {
+ log_write(0, LOG_MAIN|LOG_PANIC,
+ "programming fault, spamd_sock unexpectedly unset");
+ (void)fclose(mbox_file);
+ (void)close(spamd_sock);
+ return DEFER;
+ }
+
/* now we are connected to spamd on spamd_sock */
(void)string_format(spamd_buffer,
sizeof(spamd_buffer),
"spam acl condition: %s on spamd socket", strerror(errno));
else {
if (time(NULL) - start < SPAMD_TIMEOUT)
- goto again;
+ goto again;
log_write(0, LOG_MAIN|LOG_PANIC,
"spam acl condition: timed out writing spamd socket");
}