diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2008-11-10 22:35:24 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2008-11-10 22:35:24 +0000 |
commit | 7cfd80801e50b4d8d4dae054183ef3e33b901de9 (patch) | |
tree | 3dd8d2516fb8cc68d908b1717044604a09c69f0b | |
parent | 11802a4868ef558ab127a5dcac1207b60a1a26e4 (diff) |
- 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
-rw-r--r-- | usr.sbin/smtpd/aliases.c | 22 | ||||
-rw-r--r-- | usr.sbin/smtpd/mta.c | 12 | ||||
-rw-r--r-- | usr.sbin/smtpd/parse.y | 18 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 16 |
4 files changed, 34 insertions, 34 deletions
diff --git a/usr.sbin/smtpd/aliases.c b/usr.sbin/smtpd/aliases.c index c0b063b310a..b88c0977850 100644 --- a/usr.sbin/smtpd/aliases.c +++ b/usr.sbin/smtpd/aliases.c @@ -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; } diff --git a/usr.sbin/smtpd/mta.c b/usr.sbin/smtpd/mta.c index e7b828c4f68..1f16d0be0b5 100644 --- a/usr.sbin/smtpd/mta.c +++ b/usr.sbin/smtpd/mta.c @@ -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; } diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index d8a1b7cb55a..ab0deccb8c9 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -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; diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index e0cb5e6553f..10425aad392 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -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 { |