diff options
Diffstat (limited to '')
-rw-r--r-- | src/lib-smtp/smtp-command.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/lib-smtp/smtp-command.h b/src/lib-smtp/smtp-command.h new file mode 100644 index 0000000..94f2251 --- /dev/null +++ b/src/lib-smtp/smtp-command.h @@ -0,0 +1,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 |