From 36636aca981342ccd3f0cd956855839de72610b5 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Sun, 28 Nov 2021 19:25:55 -0500 Subject: [PATCH] Made the RBL evaluation conditional cleaner by assuming short-circuit evaluation. --- citadel/modules/smtp/serv_smtp.c | 90 +++++++++++++++----------------- do-release.sh | 2 +- 2 files changed, 43 insertions(+), 49 deletions(-) diff --git a/citadel/modules/smtp/serv_smtp.c b/citadel/modules/smtp/serv_smtp.c index f8d7466d6..fa8b731d4 100644 --- a/citadel/modules/smtp/serv_smtp.c +++ b/citadel/modules/smtp/serv_smtp.c @@ -1,35 +1,33 @@ -/* - * This module is an SMTP and ESMTP server for the Citadel system. - * It is compliant with all of the following: - * - * RFC 821 - Simple Mail Transfer Protocol - * RFC 876 - Survey of SMTP Implementations - * RFC 1047 - Duplicate messages and SMTP - * RFC 1652 - 8 bit MIME - * RFC 1869 - Extended Simple Mail Transfer Protocol - * RFC 1870 - SMTP Service Extension for Message Size Declaration - * RFC 2033 - Local Mail Transfer Protocol - * RFC 2197 - SMTP Service Extension for Command Pipelining - * RFC 2476 - Message Submission - * RFC 2487 - SMTP Service Extension for Secure SMTP over TLS - * RFC 2554 - SMTP Service Extension for Authentication - * RFC 2821 - Simple Mail Transfer Protocol - * RFC 2822 - Internet Message Format - * RFC 2920 - SMTP Service Extension for Command Pipelining - * - * The VRFY and EXPN commands have been removed from this implementation - * because nobody uses these commands anymore, except for spammers. - * - * Copyright (c) 1998-2021 by the citadel.org team - * - * This program is open source software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +// This module is an SMTP and ESMTP server for the Citadel system. +// It is compliant with all of the following: +// +// RFC 821 - Simple Mail Transfer Protocol +// RFC 876 - Survey of SMTP Implementations +// RFC 1047 - Duplicate messages and SMTP +// RFC 1652 - 8 bit MIME +// RFC 1869 - Extended Simple Mail Transfer Protocol +// RFC 1870 - SMTP Service Extension for Message Size Declaration +// RFC 2033 - Local Mail Transfer Protocol +// RFC 2197 - SMTP Service Extension for Command Pipelining +// RFC 2476 - Message Submission +// RFC 2487 - SMTP Service Extension for Secure SMTP over TLS +// RFC 2554 - SMTP Service Extension for Authentication +// RFC 2821 - Simple Mail Transfer Protocol +// RFC 2822 - Internet Message Format +// RFC 2920 - SMTP Service Extension for Command Pipelining +// +// The VRFY and EXPN commands have been removed from this implementation +// because nobody uses these commands anymore, except for spammers. +// +// Copyright (c) 1998-2021 by the citadel.org team +// +// This program is open source software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 3. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. #include "sysdep.h" #include @@ -672,23 +670,19 @@ void smtp_rcpt(void) { return; } - /* RBL check */ - if ( (!CC->logged_in) /* Don't RBL authenticated users */ - && (!SMTP->is_lmtp) ) { /* Don't RBL LMTP clients */ - if (CtdlGetConfigInt("c_rbl_at_greeting") == 0) { /* Don't RBL again if we already did it */ - if (rbl_check(CC->cs_addr, message_to_spammer)) { - if (server_shutting_down) - cprintf("421 %s\r\n", message_to_spammer); - else - cprintf("550 %s\r\n", message_to_spammer); - /* no need to free_recipients(valid), it's not allocated yet */ - return; - } - } - } + // RBL check + if ( + (!CC->logged_in) // Don't RBL authenticated users + && (!SMTP->is_lmtp) // Don't RBL LMTP clients + && (CtdlGetConfigInt("c_rbl_at_greeting") == 0) // Don't RBL if we did it at connection time + && (rbl_check(CC->cs_addr, message_to_spammer)) + ) { + cprintf("550 %s\r\n", message_to_spammer); + return; // no need to free_recipients(valid) + } // because it hasn't been allocated yet valid = validate_recipients( - ChrPtr(SMTP->OneRcpt), + (char *)ChrPtr(SMTP->OneRcpt), smtp_get_Recipients(), (SMTP->is_lmtp)? POST_LMTP: (CC->logged_in)? POST_LOGGED_IN: POST_EXTERNAL ); @@ -854,7 +848,7 @@ void smtp_data(void) { /* Submit the message into the Citadel system. */ valid = validate_recipients( - ChrPtr(SMTP->recipients), + (char *)ChrPtr(SMTP->recipients), smtp_get_Recipients(), (SMTP->is_lmtp)? POST_LMTP: (CC->logged_in)? POST_LOGGED_IN: POST_EXTERNAL ); diff --git a/do-release.sh b/do-release.sh index d6a643a62..cf71b1e5f 100755 --- a/do-release.sh +++ b/do-release.sh @@ -67,5 +67,5 @@ git commit -a -m "Release version ${NEW_VERSION} generated by do-release.sh" git tag -a v${NEW_VERSION} -m ${NEW_VERSION} echo -e '' -echo -e '\033[37m\033[1mFinished. Remember to push this commit.\033[0m' +echo -e '\033[37m\033[1mFinished. Remember to git push --tags\033[0m' echo -e '' -- 2.30.2