diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2012-08-24 13:21:57 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2012-08-24 13:21:57 +0000 |
commit | 22aa1bd02d603fe6a95e9ce704c6965215a39c99 (patch) | |
tree | 0324d5c4f48d9e0672e9200975dadbffed3ff833 | |
parent | e29f1c5920b65352836d5e7033c36b8aacc757ff (diff) |
In envelope ascii dump/load:
- remove loading of evpid.
- don't dump the msgid
- ignore msgid at load
- remove now unused functions ascii_{dump,load}_uint{32,64}_hex()
With inputs from eric@ and gilles@
ok gilles@ eric@
-rw-r--r-- | usr.sbin/smtpd/envelope.c | 61 | ||||
-rw-r--r-- | usr.sbin/smtpd/queue_backend.c | 9 | ||||
-rw-r--r-- | usr.sbin/smtpd/smtpd.h | 3 |
3 files changed, 6 insertions, 67 deletions
diff --git a/usr.sbin/smtpd/envelope.c b/usr.sbin/smtpd/envelope.c index fa0c55ce1b6..25d2628b734 100644 --- a/usr.sbin/smtpd/envelope.c +++ b/usr.sbin/smtpd/envelope.c @@ -1,4 +1,4 @@ -/* $OpenBSD: envelope.c,v 1.9 2012/08/21 20:19:46 eric Exp $ */ +/* $OpenBSD: envelope.c,v 1.10 2012/08/24 13:21:56 chl Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -48,8 +48,6 @@ static int ascii_load_uint8(uint8_t *, char *); static int ascii_load_uint16(uint16_t *, char *); static int ascii_load_uint32(uint32_t *, char *); static int ascii_load_time(time_t *, char *); -static int ascii_load_uint32_hex(uint32_t *, char *); -static int ascii_load_uint64_hex(uint64_t *, char *); static int ascii_load_type(enum delivery_type *, char *); static int ascii_load_string(char *, char *, size_t); static int ascii_load_sockaddr(struct sockaddr_storage *, char *); @@ -61,8 +59,6 @@ static int ascii_load_mta_relay_flags(uint8_t *, char *); static int ascii_dump_uint8(uint8_t, char *, size_t); static int ascii_dump_uint32(uint32_t, char *, size_t); static int ascii_dump_time(time_t, char *, size_t); -static int ascii_dump_uint32_hex(uint32_t, char *, size_t); -static int ascii_dump_uint64_hex(uint64_t, char *, size_t); static int ascii_dump_string(char *, char *, size_t); static int ascii_dump_type(enum delivery_type, char *, size_t); static int ascii_dump_mda_method(enum action_type, char *, size_t); @@ -94,7 +90,6 @@ envelope_load_buffer(struct envelope *ep, char *buf, size_t buflen) { enum envelope_field fields[] = { EVP_VERSION, - EVP_ID, EVP_MSGID, EVP_HOSTNAME, EVP_SOCKADDR, @@ -175,7 +170,6 @@ envelope_dump_buffer(struct envelope *ep, char *dest, size_t len) enum envelope_field fields[] = { EVP_VERSION, - EVP_MSGID, EVP_TYPE, EVP_HELO, EVP_HOSTNAME, @@ -269,8 +263,6 @@ envelope_ascii_field_name(enum envelope_field field) switch (field) { case EVP_VERSION: return "version"; - case EVP_ID: - return "id"; case EVP_MSGID: return "msgid"; case EVP_TYPE: @@ -323,18 +315,11 @@ envelope_ascii_field_name(enum envelope_field field) int envelope_ascii_load(enum envelope_field field, struct envelope *ep, char *buf) { - uint32_t msgid; - int r; - switch (field) { case EVP_VERSION: return ascii_load_uint32(&ep->version, buf); - case EVP_ID: - return ascii_load_uint64_hex(&ep->id, buf); case EVP_MSGID: - if ((r = ascii_load_uint32_hex(&msgid, buf))) - ep->id = msgid_to_evpid(msgid); - return (r); + return 1; case EVP_TYPE: return ascii_load_type(&ep->type, buf); case EVP_HELO: @@ -402,10 +387,6 @@ envelope_ascii_dump(enum envelope_field field, struct envelope *ep, switch (field) { case EVP_VERSION: return ascii_dump_uint32(SMTPD_ENVELOPE_VERSION, buf, len); - case EVP_ID: - return ascii_dump_uint64_hex(ep->id, buf, len); - case EVP_MSGID: - return ascii_dump_uint32_hex(evpid_to_msgid(ep->id), buf, len); case EVP_TYPE: return ascii_dump_type(ep->type, buf, len); case EVP_HELO: @@ -502,32 +483,6 @@ ascii_load_time(time_t *dest, char *buf) } static int -ascii_load_uint32_hex(uint32_t *dest, char *buf) -{ - uint64_t u; - - if (ascii_load_uint64_hex(&u, buf) == 0) - return (0); - if (u > (uint64_t)0xffffffff) - return (0); - *dest = (uint32_t)u; - return (1); -} - -static int -ascii_load_uint64_hex(uint64_t *dest, char *buf) -{ - char *endptr; - - *dest = strtoull(buf, &endptr, 16); - if (buf[0] == '\0' || *endptr != '\0') - return 0; - if (errno == ERANGE && *dest == ULLONG_MAX) - return 0; - return 1; -} - -static int ascii_load_type(enum delivery_type *dest, char *buf) { if (strcasecmp(buf, "mda") == 0) @@ -655,18 +610,6 @@ ascii_dump_time(time_t src, char *dest, size_t len) } static int -ascii_dump_uint32_hex(uint32_t src, char *dest, size_t len) -{ - return bsnprintf(dest, len, "%08" PRIx32, src); -} - -static int -ascii_dump_uint64_hex(uint64_t src, char *dest, size_t len) -{ - return bsnprintf(dest, len, "%016" PRIx64, src); -} - -static int ascii_dump_string(char *src, char *dest, size_t len) { return bsnprintf(dest, len, "%s", src); diff --git a/usr.sbin/smtpd/queue_backend.c b/usr.sbin/smtpd/queue_backend.c index c0a0f68d982..e7d8746bbd2 100644 --- a/usr.sbin/smtpd/queue_backend.c +++ b/usr.sbin/smtpd/queue_backend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue_backend.c,v 1.30 2012/08/24 13:13:13 chl Exp $ */ +/* $OpenBSD: queue_backend.c,v 1.31 2012/08/24 13:21:56 chl Exp $ */ /* * Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org> @@ -39,7 +39,7 @@ #include "smtpd.h" #include "log.h" -static const char* envelope_validate(struct envelope *, uint64_t); +static const char* envelope_validate(struct envelope *); extern struct queue_backend queue_backend_fs; @@ -247,14 +247,11 @@ queue_generate_evpid(uint32_t msgid) /**/ static const char* -envelope_validate(struct envelope *ep, uint64_t id) +envelope_validate(struct envelope *ep) { if (ep->version != SMTPD_ENVELOPE_VERSION) return "version mismatch"; - if (evpid_to_msgid(ep->id) != (evpid_to_msgid(id))) - return "msgid mismatch"; - if (memchr(ep->helo, '\0', sizeof(ep->helo)) == NULL) return "invalid helo"; if (ep->helo[0] == '\0') diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h index ea4e844936d..185d6f4b87d 100644 --- a/usr.sbin/smtpd/smtpd.h +++ b/usr.sbin/smtpd/smtpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: smtpd.h,v 1.331 2012/08/24 13:13:13 chl Exp $ */ +/* $OpenBSD: smtpd.h,v 1.332 2012/08/24 13:21:56 chl Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -424,7 +424,6 @@ TAILQ_HEAD(deliverylist, envelope); enum envelope_field { EVP_VERSION, - EVP_ID, EVP_MSGID, EVP_TYPE, EVP_HELO, |