summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2005-11-12 16:40:58 +0000
committerderaadt <deraadt@openbsd.org>2005-11-12 16:40:58 +0000
commit79592ece643803156a9b71164af7d58efa1d4a8e (patch)
tree10e226eabbb4b66f24d2b7749819b1b692fc8bcc
parentclarify how wtmp is rotated, since it was rather misleading; (diff)
downloadwireguard-openbsd-79592ece643803156a9b71164af7d58efa1d4a8e.tar.xz
wireguard-openbsd-79592ece643803156a9b71164af7d58efa1d4a8e.zip
do not stat() before open(); instead -- use fstat(); ok hshoexer
-rw-r--r--sbin/ipsecctl/parse.y11
1 files changed, 5 insertions, 6 deletions
diff --git a/sbin/ipsecctl/parse.y b/sbin/ipsecctl/parse.y
index 7d29595909d..9c420ddfae1 100644
--- a/sbin/ipsecctl/parse.y
+++ b/sbin/ipsecctl/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.34 2005/11/12 12:00:53 hshoexer Exp $ */
+/* $OpenBSD: parse.y,v 1.35 2005/11/12 16:40:58 deraadt Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -1003,16 +1003,15 @@ parsekeyfile(char *filename)
int fd;
unsigned char *hex;
- if (stat(filename, &sb) < 0)
+ if ((fd = open(filename, O_RDONLY)) < 0)
+ err(1, "parsekeyfile: open");
+ if (fstat(fd, &sb) < 0)
err(1, "parsekeyfile: stat %s", filename);
if ((sb.st_size > KEYSIZE_LIMIT) || (sb.st_size == 0))
errx(1, "parsekeyfile: key too %s", sb.st_size ? "large" :
"small");
- if ((hex = calloc(sb.st_size, sizeof(unsigned char)))
- == NULL)
+ if ((hex = calloc(sb.st_size, sizeof(unsigned char))) == NULL)
err(1, "parsekeyfile: calloc");
- if ((fd = open(filename, O_RDONLY)) < 0)
- err(1, "parsekeyfile: open");
if (read(fd, hex, sb.st_size) < sb.st_size)
err(1, "parsekeyfile: read");
close(fd);