Files
bongo/src/agents/smtp/protocol.h
T
Mario Fetka 3209fc32dd
Debian Trixie package bundle / packages (push) Successful in 15m43s
smtp: reject an empty recipient path
2026-07-28 07:18:50 +02:00

135 lines
4.8 KiB
C

/****************************************************************************
* <Novell-copyright>
* Copyright (c) 2001 Novell, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public License
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, contact Novell, Inc.
*
* To contact Novell about this file by physical or electronic mail, you
* may find current contact information at www.novell.com.
* </Novell-copyright>
****************************************************************************/
#ifndef BONGO_SMTP_PROTOCOL_H
#define BONGO_SMTP_PROTOCOL_H
#include <stddef.h>
#include <stdint.h>
/* RFC 5321 section 4.5.3.1.4 includes the terminating CRLF. */
#define SMTP_COMMAND_LINE_MAX 510U
typedef enum {
SMTP_COMMAND_UNKNOWN = 0,
SMTP_COMMAND_AUTH,
SMTP_COMMAND_BDAT,
SMTP_COMMAND_DATA,
SMTP_COMMAND_EHLO,
SMTP_COMMAND_ETRN,
SMTP_COMMAND_EXPN,
SMTP_COMMAND_HELO,
SMTP_COMMAND_HELP,
SMTP_COMMAND_MAIL,
SMTP_COMMAND_NOOP,
SMTP_COMMAND_QUIT,
SMTP_COMMAND_RCPT,
SMTP_COMMAND_RSET,
SMTP_COMMAND_SAML,
SMTP_COMMAND_SEND,
SMTP_COMMAND_SOML,
SMTP_COMMAND_STARTTLS,
SMTP_COMMAND_VRFY
} SMTPCommand;
typedef enum {
SMTP_PARAMETER_OK = 0,
SMTP_PARAMETER_SYNTAX,
SMTP_PARAMETER_UNSUPPORTED,
SMTP_PARAMETER_BINARYMIME
} SMTPParameterResult;
typedef enum {
SMTP_BODY_UNSPECIFIED = 0,
SMTP_BODY_7BIT,
SMTP_BODY_8BITMIME,
SMTP_BODY_BINARYMIME
} SMTPBodyType;
#define SMTP_ENVID_MAX 100U
#define SMTP_ORCPT_MAX 500U
#define SMTP_ORCPT_WIRE_MAX (SMTP_ORCPT_MAX * 10U + 16U)
#define SMTP_NOTIFY_SUCCESS (1U << 0)
#define SMTP_NOTIFY_FAILURE (1U << 1)
#define SMTP_NOTIFY_DELAY (1U << 2)
#define SMTP_NOTIFY_NEVER (1U << 3)
typedef struct {
SMTPBodyType body;
int size_supplied;
uint64_t size;
int smtp_utf8;
int require_tls;
int ret_supplied;
int ret_full;
int envid_supplied;
char envid[SMTP_ENVID_MAX + 1U];
int auth_supplied;
} SMTPMailParameters;
typedef struct {
int notify_supplied;
unsigned int notify;
int orcpt_supplied;
char orcpt[SMTP_ORCPT_MAX + 1U];
} SMTPRcptParameters;
SMTPCommand SMTPParseCommandLine(const char *line, size_t line_length,
const char **arguments);
int SMTPArgumentsEmpty(const char *arguments);
int SMTPParseGreetingArgument(const char *arguments, char *domain,
size_t domain_size);
int SMTPParseBdatArguments(const char *arguments, uint64_t *chunk_size,
int *last_chunk);
int SMTPParseVerifyArguments(const char *arguments, char *query,
size_t query_size, int *smtp_utf8);
int SMTPPathIsSafe(const char *path);
int SMTPRecipientPathIsValid(const char *path);
int SMTPXtextEncode(const char *value, char *encoded, size_t encoded_size);
int SMTPXtextDecode(const char *encoded, char *value, size_t value_size);
int SMTPFormatOrcptValue(const char *original, int smtp_utf8,
char *wire_value, size_t wire_value_size);
int SMTPFormatDsnMailOptions(int ret_explicit, int ret_full,
const char *envid, char *options,
size_t options_size);
int SMTPFormatDsnRcptOptions(int notify_explicit,
unsigned int notify,
const char *original_recipient,
int smtp_utf8, char *options,
size_t options_size);
int SMTPDeliveryResultFromReply(unsigned int reply_code,
const char *reply_text);
int SMTPRequireTlsHasAuthenticatedPolicy(int mx_dnssec_authenticated,
int dane_authenticated,
int mta_sts_enforced,
int web_pki_verification);
SMTPParameterResult SMTPParseMailParameters(const char *parameters,
SMTPMailParameters *result);
SMTPParameterResult SMTPParseRcptParameters(const char *parameters,
int smtp_utf8,
SMTPRcptParameters *result);
int SMTPParseReplyLine(const char *line, size_t line_length,
unsigned int *code, int *continuation,
const char **text);
#endif