diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2014-09-15 06:15:49 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2014-09-15 06:15:49 +0000 |
commit | f295c5224e8e8ce01d5f2014e82f433bb2d029c0 (patch) | |
tree | b040ad48a99c9cc60ff43f6d6c374b11fd2caa02 /lib/libc | |
parent | 305e5c9c8be4831136878e3ee72114d74f4e1a4d (diff) |
When fopen()ing internal to libc (the API doesn't support the use
of the resulting FILE *), then pass fopen() the 'e' mode letter to
mark it close-on-exec.
ok miod@
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/asr/asr.c | 6 | ||||
-rw-r--r-- | lib/libc/asr/getaddrinfo_async.c | 4 | ||||
-rw-r--r-- | lib/libc/asr/gethostnamadr_async.c | 4 | ||||
-rw-r--r-- | lib/libc/asr/getnetnamadr_async.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/fstab.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/getcap.c | 8 | ||||
-rw-r--r-- | lib/libc/gen/getgrent.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/getgrouplist.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/getttyent.c | 4 | ||||
-rw-r--r-- | lib/libc/gen/getusershell.c | 4 | ||||
-rw-r--r-- | lib/libc/locale/setrunelocale.c | 4 | ||||
-rw-r--r-- | lib/libc/net/ethers.c | 6 | ||||
-rw-r--r-- | lib/libc/net/getnetent.c | 6 | ||||
-rw-r--r-- | lib/libc/net/getprotoent.c | 6 | ||||
-rw-r--r-- | lib/libc/net/getservent.c | 6 | ||||
-rw-r--r-- | lib/libc/net/ruserok.c | 4 | ||||
-rw-r--r-- | lib/libc/rpc/getrpcent.c | 6 |
17 files changed, 42 insertions, 42 deletions
diff --git a/lib/libc/asr/asr.c b/lib/libc/asr/asr.c index eceec10804f..0498d26d3a4 100644 --- a/lib/libc/asr/asr.c +++ b/lib/libc/asr/asr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asr.c,v 1.33 2014/03/26 18:13:15 eric Exp $ */ +/* $OpenBSD: asr.c,v 1.34 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 2010-2012 Eric Faurot <eric@openbsd.org> * @@ -695,7 +695,7 @@ asr_ctx_from_file(struct asr_ctx *ac, const char *path) char buf[4096]; ssize_t r; - cf = fopen(path, "r"); + cf = fopen(path, "re"); if (cf == NULL) return (-1); @@ -920,7 +920,7 @@ asr_hostalias(struct asr_ctx *ac, const char *name, char *abuf, size_t abufsz) asr_ndots(name) != 0 || issetugid() || (file = getenv("HOSTALIASES")) == NULL || - (fp = fopen(file, "r")) == NULL) + (fp = fopen(file, "re")) == NULL) return (NULL); DPRINT("asr: looking up aliases in \"%s\"\n", file); diff --git a/lib/libc/asr/getaddrinfo_async.c b/lib/libc/asr/getaddrinfo_async.c index 1a4e7330214..1d79c8298d1 100644 --- a/lib/libc/asr/getaddrinfo_async.c +++ b/lib/libc/asr/getaddrinfo_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getaddrinfo_async.c,v 1.29 2014/07/23 21:26:25 eric Exp $ */ +/* $OpenBSD: getaddrinfo_async.c,v 1.30 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -409,7 +409,7 @@ getaddrinfo_async_run(struct asr_query *as, struct asr_result *ar) break; case ASR_DB_FILE: - f = fopen(as->as_ctx->ac_hostfile, "r"); + f = fopen(as->as_ctx->ac_hostfile, "re"); if (f == NULL) { async_set_state(as, ASR_STATE_NEXT_DB); break; diff --git a/lib/libc/asr/gethostnamadr_async.c b/lib/libc/asr/gethostnamadr_async.c index 218c055b7e4..82614f29cde 100644 --- a/lib/libc/asr/gethostnamadr_async.c +++ b/lib/libc/asr/gethostnamadr_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gethostnamadr_async.c,v 1.30 2014/07/23 21:26:25 eric Exp $ */ +/* $OpenBSD: gethostnamadr_async.c,v 1.31 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -247,7 +247,7 @@ gethostnamadr_async_run(struct asr_query *as, struct asr_result *ar) /* Try to find a match in the host file */ - if ((f = fopen(as->as_ctx->ac_hostfile, "r")) == NULL) + if ((f = fopen(as->as_ctx->ac_hostfile, "re")) == NULL) break; if (as->as_type == ASR_GETHOSTBYNAME) { diff --git a/lib/libc/asr/getnetnamadr_async.c b/lib/libc/asr/getnetnamadr_async.c index 53147ed8fc5..f31168ef005 100644 --- a/lib/libc/asr/getnetnamadr_async.c +++ b/lib/libc/asr/getnetnamadr_async.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getnetnamadr_async.c,v 1.17 2014/09/15 06:03:39 guenther Exp $ */ +/* $OpenBSD: getnetnamadr_async.c,v 1.18 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 2012 Eric Faurot <eric@openbsd.org> * @@ -178,7 +178,7 @@ getnetnamadr_async_run(struct asr_query *as, struct asr_result *ar) case ASR_DB_FILE: - if ((f = fopen(_PATH_NETWORKS, "r")) == NULL) + if ((f = fopen(_PATH_NETWORKS, "re")) == NULL) break; if (as->as_type == ASR_GETNETBYNAME) diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c index 379152bd5f0..bb757341144 100644 --- a/lib/libc/gen/fstab.c +++ b/lib/libc/gen/fstab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fstab.c,v 1.19 2013/06/01 01:42:55 tedu Exp $ */ +/* $OpenBSD: fstab.c,v 1.20 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1980, 1988, 1993 * The Regents of the University of California. All rights reserved. @@ -196,7 +196,7 @@ setfsent(void) goto fail; } - if ((_fs_fp = fopen(_PATH_FSTAB, "r"))) + if ((_fs_fp = fopen(_PATH_FSTAB, "re"))) return(1); fail: diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c index b2d0d616cd3..797ddb0cecd 100644 --- a/lib/libc/gen/getcap.c +++ b/lib/libc/gen/getcap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getcap.c,v 1.30 2011/10/14 16:33:53 millert Exp $ */ +/* $OpenBSD: getcap.c,v 1.31 2014/09/15 06:15:48 guenther Exp $ */ /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -272,7 +272,7 @@ getent(char **cap, u_int *len, char **db_array, FILE *fp, *cap = cbuf; return (retval); } else { - fp = fopen(*db_p, "r"); + fp = fopen(*db_p, "re"); if (fp == NULL) { /* No error on unfound file. */ continue; @@ -670,7 +670,7 @@ cgetnext(char **cap, char **db_array) if (dbp == NULL) dbp = db_array; - if (pfp == NULL && (pfp = fopen(*dbp, "r")) == NULL) + if (pfp == NULL && (pfp = fopen(*dbp, "re")) == NULL) goto done; /* @@ -722,7 +722,7 @@ cgetnext(char **cap, char **db_array) status = 0; goto done; } else if ((pfp = - fopen(*dbp, "r")) == NULL) { + fopen(*dbp, "re")) == NULL) { goto done; } else continue; diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index e15d14e3b23..638d693404d 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getgrent.c,v 1.40 2014/03/12 10:54:36 schwarze Exp $ */ +/* $OpenBSD: getgrent.c,v 1.41 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -207,7 +207,7 @@ start_gr(void) #endif return(1); } - return((_gr_fp = fopen(_PATH_GROUP, "r")) ? 1 : 0); + return((_gr_fp = fopen(_PATH_GROUP, "re")) ? 1 : 0); } void diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c index 37d321bdb45..651231124dd 100644 --- a/lib/libc/gen/getgrouplist.c +++ b/lib/libc/gen/getgrouplist.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getgrouplist.c,v 1.23 2014/01/22 09:58:28 jsg Exp $ */ +/* $OpenBSD: getgrouplist.c,v 1.24 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 2008 Ingo Schwarze <schwarze@usta.de> * Copyright (c) 1991, 1993 @@ -114,7 +114,7 @@ _read_netid(const char *key, uid_t uid, gid_t *groups, int *ngroups, char line[MAXLINELENGTH], *p; int found = 0; - fp = fopen(_PATH_NETID, "r"); + fp = fopen(_PATH_NETID, "re"); if (!fp) return (0); while (!found && fgets(line, sizeof(line), fp)) { diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c index c95cb9e574b..33d788b7775 100644 --- a/lib/libc/gen/getttyent.c +++ b/lib/libc/gen/getttyent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getttyent.c,v 1.13 2013/11/24 23:51:29 deraadt Exp $ */ +/* $OpenBSD: getttyent.c,v 1.14 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -181,7 +181,7 @@ setttyent(void) if (tf) { rewind(tf); return (1); - } else if ((tf = fopen(_PATH_TTYS, "r"))) + } else if ((tf = fopen(_PATH_TTYS, "re"))) return (1); return (0); } diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c index 56ad2093b72..c3517b19e06 100644 --- a/lib/libc/gen/getusershell.c +++ b/lib/libc/gen/getusershell.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getusershell.c,v 1.13 2014/01/19 21:01:06 tobias Exp $ */ +/* $OpenBSD: getusershell.c,v 1.14 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1985, 1993 * The Regents of the University of California. All rights reserved. @@ -95,7 +95,7 @@ initshells(void) if (strings != NULL) free(strings); strings = NULL; - if ((fp = fopen(_PATH_SHELLS, "r")) == NULL) + if ((fp = fopen(_PATH_SHELLS, "re")) == NULL) return (okshells); if (fstat(fileno(fp), &statb) == -1) { (void)fclose(fp); diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c index 247f6854ee8..9b701203758 100644 --- a/lib/libc/locale/setrunelocale.c +++ b/lib/libc/locale/setrunelocale.c @@ -1,4 +1,4 @@ -/* $OpenBSD: setrunelocale.c,v 1.10 2013/06/01 20:02:53 stsp Exp $ */ +/* $OpenBSD: setrunelocale.c,v 1.11 2014/09/15 06:15:48 guenther Exp $ */ /* $NetBSD: setrunelocale.c,v 1.14 2003/08/07 16:43:07 agc Exp $ */ /*- @@ -137,7 +137,7 @@ _newrunelocale(const char *path) if (rl) return 0; - if ((fp = fopen(path, "r")) == NULL) + if ((fp = fopen(path, "re")) == NULL) return ENOENT; if ((rl = _Read_RuneMagi(fp)) != NULL) diff --git a/lib/libc/net/ethers.c b/lib/libc/net/ethers.c index af31bb8e607..07f1da33066 100644 --- a/lib/libc/net/ethers.c +++ b/lib/libc/net/ethers.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ethers.c,v 1.21 2013/11/24 23:51:28 deraadt Exp $ */ +/* $OpenBSD: ethers.c,v 1.22 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> @@ -112,7 +112,7 @@ ether_ntohost(char *hostname, struct ether_addr *e) trylen = strlen(trybuf); #endif - f = fopen(_PATH_ETHERS, "r"); + f = fopen(_PATH_ETHERS, "re"); if (f == NULL) return (-1); while ((p = fgetln(f, &len)) != NULL) { @@ -165,7 +165,7 @@ ether_hostton(const char *hostname, struct ether_addr *e) int hostlen = strlen(hostname); #endif - f = fopen(_PATH_ETHERS, "r"); + f = fopen(_PATH_ETHERS, "re"); if (f==NULL) return (-1); diff --git a/lib/libc/net/getnetent.c b/lib/libc/net/getnetent.c index 57fe459e2bb..14c39f1482f 100644 --- a/lib/libc/net/getnetent.c +++ b/lib/libc/net/getnetent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getnetent.c,v 1.13 2012/04/10 16:41:10 eric Exp $ */ +/* $OpenBSD: getnetent.c,v 1.14 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -48,7 +48,7 @@ void setnetent(int f) { if (netf == NULL) - netf = fopen(_PATH_NETWORKS, "r" ); + netf = fopen(_PATH_NETWORKS, "re" ); else rewind(netf); _net_stayopen |= f; @@ -70,7 +70,7 @@ getnetent(void) char *p, *cp, **q; size_t len; - if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL) + if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "re" )) == NULL) return (NULL); again: if ((p = fgetln(netf, &len)) == NULL) diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c index f0705e0765e..87060b7b3c9 100644 --- a/lib/libc/net/getprotoent.c +++ b/lib/libc/net/getprotoent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getprotoent.c,v 1.10 2007/09/02 15:19:17 deraadt Exp $ */ +/* $OpenBSD: getprotoent.c,v 1.11 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -42,7 +42,7 @@ void setprotoent_r(int f, struct protoent_data *pd) { if (pd->fp == NULL) - pd->fp = fopen(_PATH_PROTOCOLS, "r" ); + pd->fp = fopen(_PATH_PROTOCOLS, "re" ); else rewind(pd->fp); pd->stayopen |= f; @@ -71,7 +71,7 @@ getprotoent_r(struct protoent *pe, struct protoent_data *pd) long l; int serrno; - if (pd->fp == NULL && (pd->fp = fopen(_PATH_PROTOCOLS, "r" )) == NULL) + if (pd->fp == NULL && (pd->fp = fopen(_PATH_PROTOCOLS, "re" )) == NULL) return (-1); again: if ((p = fgetln(pd->fp, &len)) == NULL) diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c index c81a4cf3e29..7e3293389d6 100644 --- a/lib/libc/net/getservent.c +++ b/lib/libc/net/getservent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getservent.c,v 1.12 2007/09/02 15:19:17 deraadt Exp $ */ +/* $OpenBSD: getservent.c,v 1.13 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -42,7 +42,7 @@ void setservent_r(int f, struct servent_data *sd) { if (sd->fp == NULL) - sd->fp = fopen(_PATH_SERVICES, "r" ); + sd->fp = fopen(_PATH_SERVICES, "re" ); else rewind(sd->fp); sd->stayopen |= f; @@ -71,7 +71,7 @@ getservent_r(struct servent *se, struct servent_data *sd) long l; int serrno; - if (sd->fp == NULL && (sd->fp = fopen(_PATH_SERVICES, "r" )) == NULL) + if (sd->fp == NULL && (sd->fp = fopen(_PATH_SERVICES, "re" )) == NULL) return (-1); again: if ((p = fgetln(sd->fp, &len)) == NULL) diff --git a/lib/libc/net/ruserok.c b/lib/libc/net/ruserok.c index 21646c156ba..4d0adfbe4ef 100644 --- a/lib/libc/net/ruserok.c +++ b/lib/libc/net/ruserok.c @@ -118,7 +118,7 @@ iruserok_sa(const void *raddr, int rlen, int superuser, const char *ruser, sa = (struct sockaddr *)raddr; first = 1; - hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "r"); + hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re"); again: if (hostf) { if (__ivaliduser_sa(hostf, sa, rlen, luser, ruser) == 0) { @@ -144,7 +144,7 @@ again: */ uid = geteuid(); (void)seteuid(pwd->pw_uid); - hostf = fopen(pbuf, "r"); + hostf = fopen(pbuf, "re"); (void)seteuid(uid); if (hostf == NULL) diff --git a/lib/libc/rpc/getrpcent.c b/lib/libc/rpc/getrpcent.c index a04bff84ae1..ebe3031fe7b 100644 --- a/lib/libc/rpc/getrpcent.c +++ b/lib/libc/rpc/getrpcent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getrpcent.c,v 1.15 2010/09/01 14:43:34 millert Exp $ */ +/* $OpenBSD: getrpcent.c,v 1.16 2014/09/15 06:15:48 guenther Exp $ */ /* * Copyright (c) 2010, Oracle America, Inc. @@ -110,7 +110,7 @@ setrpcent(int f) if (d == NULL) return; if (d->rpcf == NULL) - d->rpcf = fopen(RPCDB, "r"); + d->rpcf = fopen(RPCDB, "re"); else rewind(d->rpcf); d->stayopen |= f; @@ -136,7 +136,7 @@ getrpcent(void) if (d == NULL) return(NULL); - if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "r")) == NULL) + if (d->rpcf == NULL && (d->rpcf = fopen(RPCDB, "re")) == NULL) return (NULL); /* -1 so there is room to append a \n below */ if (fgets(d->line, sizeof(d->line) - 1, d->rpcf) == NULL) |