abort connection after 25 bad commands
authorEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 1 Mar 1994 02:03:47 +0000 (18:03 -0800)
committerEric Allman <eric@ucbvax.Berkeley.EDU>
Tue, 1 Mar 1994 02:03:47 +0000 (18:03 -0800)
SCCS-vsn: usr.sbin/sendmail/src/srvrsmtp.c 8.30

usr/src/usr.sbin/sendmail/src/srvrsmtp.c

index f8990b7..0eadaf8 100644 (file)
@@ -10,9 +10,9 @@
 
 #ifndef lint
 #ifdef SMTP
 
 #ifndef lint
 #ifdef SMTP
-static char sccsid[] = "@(#)srvrsmtp.c 8.29 (Berkeley) %G% (with SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.30 (Berkeley) %G% (with SMTP)";
 #else
 #else
-static char sccsid[] = "@(#)srvrsmtp.c 8.29 (Berkeley) %G% (without SMTP)";
+static char sccsid[] = "@(#)srvrsmtp.c 8.30 (Berkeley) %G% (without SMTP)";
 #endif
 #endif /* not lint */
 
 #endif
 #endif /* not lint */
 
@@ -95,6 +95,8 @@ char  *CurSmtpClient;                 /* who's at the other end of channel */
 
 static char    *skipword();
 
 
 static char    *skipword();
 
+#define MAXBADCOMMANDS 25              /* maximum number of bad commands */
+
 smtp(e)
        register ENVELOPE *e;
 {
 smtp(e)
        register ENVELOPE *e;
 {
@@ -627,6 +629,7 @@ smtp(e)
                  case CMDQUIT:         /* quit -- leave mail */
                        message("221 %s closing connection", MyHostName);
 
                  case CMDQUIT:         /* quit -- leave mail */
                        message("221 %s closing connection", MyHostName);
 
+doquit:
                        /* avoid future 050 messages */
                        disconnect(1, e);
 
                        /* avoid future 050 messages */
                        disconnect(1, e);
 
@@ -678,6 +681,13 @@ smtp(e)
                        /* FALL THROUGH */
 
                  case CMDERROR:        /* unknown command */
                        /* FALL THROUGH */
 
                  case CMDERROR:        /* unknown command */
+                       if (++badcommands > MAXBADCOMMANDS)
+                       {
+                               message("421 %s Too many bad commands; closing connection",
+                                       MyHostName);
+                               goto doquit;
+                       }
+
                        message("500 Command unrecognized");
                        break;
 
                        message("500 Command unrecognized");
                        break;