1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-10 06:47:55 -08:00

- define MAX_LINE_SIZE which is the maximum length of a line we allow from

a client. it must be set to the highest value we have from all of
	the extensions which are/will be implemented.
- replace all occurences of STRLEN define with MAX_LINE_SIZE, kill STRLEN
This commit is contained in:
gilles 2008-11-10 22:35:23 +00:00
parent bd5bb70c9d
commit e5836a4449
4 changed files with 34 additions and 34 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: aliases.c,v 1.4 2008/11/10 03:55:36 tedu Exp $ */
/* $OpenBSD: aliases.c,v 1.5 2008/11/10 22:35:23 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@ -154,7 +154,7 @@ aliases_virtual_exist(struct smtpd *env, struct path *path)
DBT val;
DB *aliasesdb;
struct map *map;
char strkey[STRLEN];
char strkey[MAX_LINE_SIZE];
int spret;
map = map_findbyname(env, "virtual");
@ -170,8 +170,8 @@ aliases_virtual_exist(struct smtpd *env, struct path *path)
if (aliasesdb == NULL)
return 0;
spret = snprintf(strkey, STRLEN, "%s@%s", path->user, path->domain);
if (spret == -1 || spret >= STRLEN) {
spret = snprintf(strkey, MAX_LINE_SIZE, "%s@%s", path->user, path->domain);
if (spret == -1 || spret >= MAX_LINE_SIZE) {
aliasesdb->close(aliasesdb);
return 0;
}
@ -181,8 +181,8 @@ aliases_virtual_exist(struct smtpd *env, struct path *path)
if ((ret = aliasesdb->get(aliasesdb, &key, &val, 0)) != 0) {
spret = snprintf(strkey, STRLEN, "@%s", path->domain);
if (spret == -1 || spret >= STRLEN) {
spret = snprintf(strkey, MAX_LINE_SIZE, "@%s", path->domain);
if (spret == -1 || spret >= MAX_LINE_SIZE) {
aliasesdb->close(aliasesdb);
return 0;
}
@ -213,7 +213,7 @@ aliases_virtual_get(struct smtpd *env, struct aliaseslist *aliases,
struct alias *aliasp;
struct alias *nextalias;
struct map *map;
char strkey[STRLEN];
char strkey[MAX_LINE_SIZE];
int spret;
map = map_findbyname(env, "virtual");
@ -229,8 +229,8 @@ aliases_virtual_get(struct smtpd *env, struct aliaseslist *aliases,
if (aliasesdb == NULL)
return 0;
spret = snprintf(strkey, STRLEN, "%s@%s", path->user, path->domain);
if (spret == -1 || spret >= STRLEN) {
spret = snprintf(strkey, MAX_LINE_SIZE, "%s@%s", path->user, path->domain);
if (spret == -1 || spret >= MAX_LINE_SIZE) {
aliasesdb->close(aliasesdb);
return 0;
}
@ -240,8 +240,8 @@ aliases_virtual_get(struct smtpd *env, struct aliaseslist *aliases,
if ((ret = aliasesdb->get(aliasesdb, &key, &val, 0)) != 0) {
spret = snprintf(strkey, STRLEN, "@%s", path->domain);
if (spret == -1 || spret >= STRLEN) {
spret = snprintf(strkey, MAX_LINE_SIZE, "@%s", path->domain);
if (spret == -1 || spret >= MAX_LINE_SIZE) {
aliasesdb->close(aliasesdb);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: mta.c,v 1.3 2008/11/10 02:34:50 gilles Exp $ */
/* $OpenBSD: mta.c,v 1.4 2008/11/10 22:35:23 gilles Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@ -404,7 +404,7 @@ mta_write(int s, short event, void *arg)
bufferevent_free(batchp->bev);
batchp->bev = NULL;
}
strlcpy(batchp->errorline, "connection timed-out.", STRLEN);
strlcpy(batchp->errorline, "connection timed-out.", MAX_LINE_SIZE);
ret = 0;
while (batchp->ss_off < batchp->ss_cnt &&
@ -469,7 +469,7 @@ mta_reply_handler(struct bufferevent *bev, void *arg)
if (errstr || code < 100) {
/* Server sent invalid line, protocol error */
batchp->status |= S_BATCH_PERMFAILURE;
strlcpy(batchp->errorline, line, STRLEN);
strlcpy(batchp->errorline, line, MAX_LINE_SIZE);
mta_batch_update_queue(batchp);
return 0;
}
@ -495,7 +495,7 @@ mta_reply_handler(struct bufferevent *bev, void *arg)
case 450:
case 451:
batchp->status |= S_BATCH_TEMPFAILURE;
strlcpy(batchp->errorline, line, STRLEN);
strlcpy(batchp->errorline, line, MAX_LINE_SIZE);
mta_batch_update_queue(batchp);
return 0;
@ -506,7 +506,7 @@ mta_reply_handler(struct bufferevent *bev, void *arg)
case 550:
if (batchp->state == S_RCPT) {
batchp->messagep->status = (S_MESSAGE_REJECTED|S_MESSAGE_PERMFAILURE);
strlcpy(batchp->messagep->session_errorline, line, STRLEN);
strlcpy(batchp->messagep->session_errorline, line, MAX_LINE_SIZE);
break;
}
case 354:
@ -530,7 +530,7 @@ mta_reply_handler(struct bufferevent *bev, void *arg)
log_debug("Ouch, SMTP session returned unhandled %d status.", code);
batchp->status |= S_BATCH_PERMFAILURE;
strlcpy(batchp->errorline, line, STRLEN);
strlcpy(batchp->errorline, line, MAX_LINE_SIZE);
mta_batch_update_queue(batchp);
return 0;
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: parse.y,v 1.7 2008/11/10 17:24:24 deraadt Exp $ */
/* $OpenBSD: parse.y,v 1.8 2008/11/10 22:35:23 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@ -453,8 +453,8 @@ mapref : STRING {
free(m);
YYERROR;
}
spret = snprintf(m->m_name, STRLEN, "<dynamic(%u)>", m->m_id);
if (spret == -1 || spret >= STRLEN)
spret = snprintf(m->m_name, MAX_LINE_SIZE, "<dynamic(%u)>", m->m_id);
if (spret == -1 || spret >= MAX_LINE_SIZE)
fatal("snprintf");
m->m_flags |= F_DYNAMIC|F_USED;
m->m_type = T_SINGLE;
@ -528,8 +528,8 @@ mapref : STRING {
free(m);
YYERROR;
}
spret = snprintf(m->m_name, STRLEN, "<dynamic(%u)>", m->m_id);
if (spret == -1 || spret >= STRLEN)
spret = snprintf(m->m_name, MAX_LINE_SIZE, "<dynamic(%u)>", m->m_id);
if (spret == -1 || spret >= MAX_LINE_SIZE)
fatal("snprintf");
m->m_flags |= F_DYNAMIC|F_USED;
m->m_type = T_LIST;
@ -555,8 +555,8 @@ mapref : STRING {
free(m);
YYERROR;
}
spret = snprintf(m->m_name, STRLEN, "<dynamic(%u)>", m->m_id);
if (spret == -1 || spret >= STRLEN)
spret = snprintf(m->m_name, MAX_LINE_SIZE, "<dynamic(%u)>", m->m_id);
if (spret == -1 || spret >= MAX_LINE_SIZE)
fatal("snprintf");
m->m_flags |= F_DYNAMIC|F_USED;
m->m_type = T_HASH;
@ -682,8 +682,8 @@ from : FROM mapref {
free(m);
YYERROR;
}
spret = snprintf(m->m_name, STRLEN, "<dynamic(%u)>", m->m_id);
if (spret == -1 || spret >= STRLEN)
spret = snprintf(m->m_name, MAX_LINE_SIZE, "<dynamic(%u)>", m->m_id);
if (spret == -1 || spret >= MAX_LINE_SIZE)
fatal("snprintf");
m->m_flags |= F_DYNAMIC|F_USED;
m->m_type = T_SINGLE;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: smtpd.h,v 1.6 2008/11/10 21:29:18 chl Exp $ */
/* $OpenBSD: smtpd.h,v 1.7 2008/11/10 22:35:23 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@ -19,12 +19,12 @@
#define CONF_FILE "/etc/mail/smtpd.conf"
#define MAX_LISTEN 16
#define STRLEN 1024
#define PROC_COUNT 8
#define READ_BUF_SIZE 32768
#define MAX_NAME_SIZE 64
/* sizes include the tailing '\0' */
#define MAX_LINE_SIZE 1024
#define MAX_LOCALPART_SIZE 65
#define MAX_DOMAINPART_SIZE MAXHOSTNAMELEN
@ -254,7 +254,7 @@ enum mapel_type {
struct mapel {
TAILQ_ENTRY(mapel) me_entry;
union mapel_data {
char med_string[STRLEN];
char med_string[MAX_LINE_SIZE];
struct netaddr med_addr;
} me_key;
union mapel_data me_val;
@ -265,7 +265,7 @@ struct map {
#define F_USED 0x01
#define F_DYNAMIC 0x02
u_int8_t m_flags;
char m_name[STRLEN];
char m_name[MAX_LINE_SIZE];
objid_t m_id;
enum map_type m_type;
enum mapel_type m_eltype;
@ -372,7 +372,7 @@ struct submit_status {
union {
struct path path;
char msgid[MAXPATHLEN];
char errormsg[STRLEN];
char errormsg[MAX_LINE_SIZE];
} u;
struct sockaddr_storage ss;
};
@ -422,7 +422,7 @@ struct message {
char session_helo[MAXHOSTNAMELEN];
char session_hostname[MAXHOSTNAMELEN];
char session_errorline[STRLEN];
char session_errorline[MAX_LINE_SIZE];
struct sockaddr_storage session_ss;
struct path sender;
@ -488,7 +488,7 @@ struct batch {
char message_id[MAXPATHLEN];
char hostname[MAXHOSTNAMELEN];
char errorline[STRLEN];
char errorline[MAX_LINE_SIZE];
u_int8_t getaddrinfo_error;
struct sockaddr_storage ss[MXARRAYSIZE*2];
@ -550,7 +550,7 @@ struct listener {
struct session_auth_req {
u_int64_t session_id;
char buffer[STRLEN];
char buffer[MAX_LINE_SIZE];
};
struct session_auth_reply {