Skip to content

Commit

Permalink
net_smtp: Fix misleading error message.
Browse files Browse the repository at this point in the history
If a client immediately disconnected after receiving the SMTP banner,
a warning would be logged about a pregreeting of 0 bytes, which is
misleading since the client actually disconnected without sending
anything. Add a code path to detect this and simply return -1.
  • Loading branch information
InterLinked1 committed Nov 14, 2024
1 parent 8b04f98 commit dc37044
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nets/net_smtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,11 @@ static int handle_connect(struct smtp_session *smtp)
bbs_error("ioctl failed: %s\n", strerror(errno));
return -1;
}
if (!bytes) {
/* Client disconnected, same as read returning 0. */
bbs_debug(3, "Client appears to have disconnected\n");
return -1;
}
bbs_warning("Pregreet: %lu bytes received before banner finished\n", bytes);
smtp->failures += 3;
if (smtp_tarpit(smtp, 220, "Waiting for service to initialize...")) {
Expand Down

0 comments on commit dc37044

Please sign in to comment.