haraka / Haraka

A fast, highly extensible, and event driven SMTP server

Home Page:https://haraka.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

double hook invocation

celesteking opened this issue · comments

Assume there's a plugin that's hooking up connect and returning DENY.
Assume there's a second plugin that tarpits quit.

Then, connect hook would switch connection.state into LOOP.
Client would send QUIT once, then would send another QUIT while there's a tarpit active, which will lead to double hook invocation and a crash.

    connect_respond (retval, msg) {
            case constants.deny:
                this.loop_respond(554, msg || "Your mail is not welcome here");
                break;
// --snip--
    loop_respond (code, msg) {
        if (this.state >= states.DISCONNECTING) return;
        this.state = states.LOOP;
// --snip--
     else if (this.state === states.LOOP) {
            // Allow QUIT
            if (this.current_line.toUpperCase() === 'QUIT') {
                this.cmd_quit();