diff options
author | 2014-08-15 03:51:40 +0000 | |
---|---|---|
committer | 2014-08-15 03:51:40 +0000 | |
commit | 0205f8e66ce8c2d9c439542953f237a17f23b194 (patch) | |
tree | 145b45ce27a69aca56b4834c4cd72e953fad812f /lib/libc/db | |
parent | Create a function which loads sgd in the mfi_iop_ops struct so that skinny (diff) | |
download | wireguard-openbsd-0205f8e66ce8c2d9c439542953f237a17f23b194.tar.xz wireguard-openbsd-0205f8e66ce8c2d9c439542953f237a17f23b194.zip |
Use O_CLOEXEC wherever we open a file and then call fcntl(F_SETFD, FD_CLOEXEC)
on it, simplifying error checking, reducing system calls, and improving
thread-safety for libraries.
ok miod@
Diffstat (limited to 'lib/libc/db')
-rw-r--r-- | lib/libc/db/hash/hash.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index 4f428e86377..389afb5f8a3 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hash.c,v 1.24 2013/04/29 00:28:23 okan Exp $ */ +/* $OpenBSD: hash.c,v 1.25 2014/08/15 03:51:40 guenther Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -115,9 +115,8 @@ __hash_open(const char *file, int flags, int mode, hashp->flags = flags; if (file) { - if ((hashp->fp = open(file, flags, mode)) == -1) + if ((hashp->fp = open(file, flags | O_CLOEXEC, mode)) == -1) RETURN_ERROR(errno, error0); - (void)fcntl(hashp->fp, F_SETFD, FD_CLOEXEC); new_table = fstat(hashp->fp, &statbuf) == 0 && statbuf.st_size == 0 && (flags & O_ACCMODE) != O_RDONLY; } else |