diff options
author | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-01-02 19:52:54 +0000 |
---|---|---|
committer | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2009-01-02 19:52:54 +0000 |
commit | a7487b767b66b30a8946c509c05cf7be68529cde (patch) | |
tree | 8d0cc229db04bad1ee25cb3e86f508288d2f22f4 | |
parent | 5a65e173e7e040a9b185e0b37656e0c7aa330575 (diff) |
cleanup queue_load_envelope; ok gilles@
-rw-r--r-- | usr.sbin/smtpd/queue.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/usr.sbin/smtpd/queue.c b/usr.sbin/smtpd/queue.c index 9f5f366607c..03afe693c7b 100644 --- a/usr.sbin/smtpd/queue.c +++ b/usr.sbin/smtpd/queue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: queue.c,v 1.40 2009/01/01 16:15:47 jacekm Exp $ */ +/* $OpenBSD: queue.c,v 1.41 2009/01/02 19:52:53 jacekm Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -905,25 +905,27 @@ int queue_load_envelope(struct message *messagep, char *evpid) { char pathname[MAXPATHLEN]; - u_int16_t hval; - FILE *fp; char msgid[MAXPATHLEN]; + FILE *fp; - strlcpy(msgid, evpid, MAXPATHLEN); + if (strlcpy(msgid, evpid, MAXPATHLEN) >= MAXPATHLEN) + fatalx("queue_load_envelope: truncation"); *strrchr(msgid, '.') = '\0'; - hval = queue_hash(msgid); if (! bsnprintf(pathname, MAXPATHLEN, "%s/%d/%s%s/%s", PATH_QUEUE, - hval, msgid, PATH_ENVELOPES, evpid)) - return 0; + queue_hash(msgid), msgid, PATH_ENVELOPES, evpid)) + fatalx("queue_load_envelope: snprintf"); fp = fopen(pathname, "r"); - if (fp == NULL) - return 0; - + if (fp == NULL) { + if (errno == ENOENT) + return 0; + if (errno == ENOSPC || errno == ENFILE) + return 0; + fatal("queue_load_envelope: fopen"); + } if (fread(messagep, sizeof(struct message), 1, fp) != 1) fatal("queue_load_envelope: fread"); - fclose(fp); return 1; |