Coverage Report

Created: 2025-08-29 07:18

/src/dovecot/src/lib-smtp/smtp-server-cmd-noop.c
Line
Count
Source (jump to first uncovered line)
1
/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
2
3
#include "lib.h"
4
#include "smtp-syntax.h"
5
6
#include "smtp-server-private.h"
7
8
/* NOOP command */
9
10
void smtp_server_cmd_noop(struct smtp_server_cmd_ctx *cmd,
11
        const char *params)
12
5.26k
{
13
5.26k
  struct smtp_server_connection *conn = cmd->conn;
14
5.26k
  struct smtp_server_command *command = cmd->cmd;
15
5.26k
  const struct smtp_server_callbacks *callbacks = conn->callbacks;
16
5.26k
  const char *param, *error;
17
5.26k
  int ret;
18
19
  /* "NOOP" [ SP String ] CRLF */
20
5.26k
  ret = smtp_string_parse(params, &param, &error);
21
5.26k
  if (ret < 0) {
22
1.75k
    smtp_server_reply(cmd, 501, "5.5.4",
23
1.75k
          "Invalid string parameter: %s",
24
1.75k
          error);
25
1.75k
    return;
26
1.75k
  }
27
28
3.50k
  smtp_server_command_input_lock(cmd);
29
30
3.50k
  smtp_server_command_ref(command);
31
3.50k
  if (callbacks != NULL && callbacks->conn_cmd_noop != NULL) {
32
    /* specific implementation of NOOP command */
33
0
    ret = callbacks->conn_cmd_noop(conn->context, cmd);
34
0
    if (ret <= 0) {
35
0
      i_assert(ret == 0 ||
36
0
         smtp_server_command_is_replied(command));
37
      /* command is waiting for external event or it failed */
38
0
      smtp_server_command_unref(&command);
39
0
      return;
40
0
    }
41
0
  }
42
3.50k
  if (!smtp_server_command_is_replied(command))
43
3.50k
    smtp_server_cmd_noop_reply_success(cmd);
44
3.50k
  smtp_server_command_unref(&command);
45
3.50k
}
46
47
void smtp_server_cmd_noop_reply_success(struct smtp_server_cmd_ctx *cmd)
48
3.50k
{
49
3.50k
       i_assert(cmd->cmd->reg->func == smtp_server_cmd_noop);
50
51
3.50k
       smtp_server_reply(cmd, 250, "2.0.0", "OK");
52
3.50k
}