blob: 94f225169fb956504fd72b3837ac48a5f0c136e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#ifndef SMTP_COMMAND_H
#define SMTP_COMMAND_H
#define SMTP_COMMAND_DEFAULT_MAX_PARAMETERS_SIZE 4*1024
#define SMTP_COMMAND_DEFAULT_MAX_AUTH_SIZE 8*1024
#define SMTP_COMMAND_DEFAULT_MAX_DATA_SIZE 40*1024*1024
struct smtp_command_limits {
/* Maximum size of command parameters, starting after first space */
size_t max_parameters_size;
/* Maximum size of authentication response */
size_t max_auth_size;
/* Absolute maximum size of command data, beyond which the parser yields
a fatal error; i.e. closing the connection in the server. This should
be higher than a normal message size limit, which would return a
normal informative error. The limit here just serves to protect
against abuse. */
uoff_t max_data_size;
};
struct smtp_command {
const char *name;
const char *parameters;
};
static inline void
smtp_command_limits_merge(struct smtp_command_limits *limits,
const struct smtp_command_limits *new_limits)
{
if (new_limits->max_parameters_size > 0)
limits->max_parameters_size = new_limits->max_parameters_size;
if (new_limits->max_auth_size > 0)
limits->max_auth_size = new_limits->max_auth_size;
if (new_limits->max_data_size > 0)
limits->max_data_size = new_limits->max_data_size;
}
#endif
|