Coverage Report

Created: 2026-01-17 06:58

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dovecot/src/lib-smtp/smtp-server-cmd-quit.c
Line
Count
Source
1
/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
2
3
#include "lib.h"
4
5
#include "smtp-server-private.h"
6
7
/* QUIT command */
8
9
void smtp_server_cmd_quit(struct smtp_server_cmd_ctx *cmd,
10
            const char *params)
11
448
{
12
448
  struct smtp_server_connection *conn = cmd->conn;
13
448
  struct smtp_server_command *command = cmd->cmd;
14
448
  const struct smtp_server_callbacks *callbacks = conn->callbacks;
15
448
  int ret;
16
17
  /* "QUIT" CRLF */
18
448
  if (*params != '\0') {
19
377
    smtp_server_reply(cmd,
20
377
      501, "5.5.4", "Invalid parameters");
21
377
    return;
22
377
  }
23
24
71
  smtp_server_connection_input_halt(conn);
25
26
71
  smtp_server_command_ref(command);
27
71
  if (callbacks != NULL && callbacks->conn_cmd_quit != NULL) {
28
    /* specific implementation of QUIT command */
29
0
    if ((ret = callbacks->conn_cmd_quit(conn->context, cmd)) <= 0) {
30
0
      i_assert(ret == 0 ||
31
0
         smtp_server_command_is_replied(command));
32
      /* command is waiting for external event or it failed */
33
0
      smtp_server_command_unref(&command);
34
0
      return;
35
0
    }
36
0
  }
37
71
  if (!smtp_server_command_is_replied(command)) {
38
    /* set generic QUIT success reply if none is provided */
39
71
    smtp_server_reply_quit(cmd);
40
71
  }
41
71
  smtp_server_command_unref(&command);
42
71
}