summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Longeau <chl@cvs.openbsd.org>2012-10-22 21:58:15 +0000
committerCharles Longeau <chl@cvs.openbsd.org>2012-10-22 21:58:15 +0000
commit2b2d21f49bcab1720c76ce6a51af4eac8443c703 (patch)
tree0ebcd1bf21d755ddcc8123547e6ff18d6f5f3677
parentcf30c02845d2f696316aa61527d6766622e78e69 (diff)
switch from {open,read,close}() to {fopen,fread,fclose}() in fsqueue_envelope_load(),
also fix a potential fd leak. ok gilles@ eric@
-rw-r--r--usr.sbin/smtpd/queue_fsqueue.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/usr.sbin/smtpd/queue_fsqueue.c b/usr.sbin/smtpd/queue_fsqueue.c
index 370ecce5e78..87b11046cbf 100644
--- a/usr.sbin/smtpd/queue_fsqueue.c
+++ b/usr.sbin/smtpd/queue_fsqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: queue_fsqueue.c,v 1.53 2012/08/30 18:19:50 eric Exp $ */
+/* $OpenBSD: queue_fsqueue.c,v 1.54 2012/10/22 21:58:14 chl Exp $ */
/*
* Copyright (c) 2011 Gilles Chehade <gilles@openbsd.org>
@@ -194,22 +194,21 @@ static int
fsqueue_envelope_load(uint64_t evpid, char *buf, size_t len)
{
char pathname[MAXPATHLEN];
- int fd;
+ FILE *fp;
ssize_t r;
fsqueue_envelope_path(evpid, pathname, sizeof(pathname));
- fd = open(pathname, O_RDONLY);
- if (fd == -1) {
+ fp = fopen(pathname, "r");
+ if (fp == NULL) {
if (errno == ENOENT || errno == ENFILE)
return (0);
- fatal("fsqueue_envelope_load: open");
+ fatal("fsqueue_envelope_load: fopen");
}
- if ((r = read(fd, buf, len)) == -1)
- return (0);
+ r = fread(buf, 1, len, fp);
- close(fd);
+ fclose(fp);
return (r);
}