diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2015-09-16 22:35:59 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2015-09-16 22:35:59 +0000 |
| commit | a1cb6af11976b0bc42122e5df60b8ae17503f556 (patch) | |
| tree | a10b0ccdaab43b0969228c097ee584f3d7cd047d /lib | |
| parent | 854fa44b6f7a32ff94c2a705691da6d3b703574a (diff) | |
| parent | 83981e319dfc0508987a7f6baaad5cd78b18ac59 (diff) | |
Notes
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/libc/db/recno/rec_open.c | 2 | ||||
| -rw-r--r-- | lib/libc/gen/fts-compat.c | 39 | ||||
| -rw-r--r-- | lib/libc/gen/getgrent.c | 4 | ||||
| -rw-r--r-- | lib/libc/gen/getloadavg.c | 4 | ||||
| -rw-r--r-- | lib/libc/gen/getmntinfo.c | 4 | ||||
| -rw-r--r-- | lib/libc/gen/getpwent.c | 5 | ||||
| -rw-r--r-- | lib/libc/gen/nlist.c | 25 | ||||
| -rw-r--r-- | lib/libc/gen/strtofflags.c | 9 | ||||
| -rw-r--r-- | lib/libc/gmon/gmon.c | 9 | ||||
| -rw-r--r-- | lib/libc/stdlib/heapsort.c | 11 | ||||
| -rw-r--r-- | lib/libc/stdlib/merge.c | 18 | ||||
| -rw-r--r-- | lib/libc/stdlib/radixsort.c | 30 | ||||
| -rw-r--r-- | lib/libc/sys/setuid.2 | 9 |
13 files changed, 46 insertions, 123 deletions
diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c index dd286c092ab6..8fce730f2799 100644 --- a/lib/libc/db/recno/rec_open.c +++ b/lib/libc/db/recno/rec_open.c @@ -64,7 +64,7 @@ __rec_open(const char *fname, int flags, int mode, const RECNOINFO *openinfo, int rfd, sverrno; /* Open the user's file -- if this fails, we're done. */ - if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0) + if (fname != NULL && (rfd = _open(fname, flags | O_CLOEXEC, mode)) < 0) return (NULL); /* Create a btree in memory (backed by disk). */ diff --git a/lib/libc/gen/fts-compat.c b/lib/libc/gen/fts-compat.c index 1be41da11539..105b064a6c4e 100644 --- a/lib/libc/gen/fts-compat.c +++ b/lib/libc/gen/fts-compat.c @@ -635,9 +635,7 @@ __fts_set_clientptr_44bsd(FTS *sp, void *clientptr) * been found, cutting the stat calls by about 2/3. */ static FTSENT * -fts_build(sp, type) - FTS *sp; - int type; +fts_build(FTS *sp, int type) { struct dirent *dp; FTSENT *p, *head; @@ -901,10 +899,7 @@ mem1: saved_errno = errno; } static u_short -fts_stat(sp, p, follow) - FTS *sp; - FTSENT *p; - int follow; +fts_stat(FTS *sp, FTSENT *p, int follow) { FTSENT *t; dev_t dev; @@ -999,10 +994,7 @@ fts_compar(const void *a, const void *b) } static FTSENT * -fts_sort(sp, head, nitems) - FTS *sp; - FTSENT *head; - int nitems; +fts_sort(FTS *sp, FTSENT *head, int nitems) { FTSENT **ap, *p; @@ -1031,10 +1023,7 @@ fts_sort(sp, head, nitems) } static FTSENT * -fts_alloc(sp, name, namelen) - FTS *sp; - char *name; - int namelen; +fts_alloc(FTS *sp, char *name, int namelen) { FTSENT *p; size_t len; @@ -1081,8 +1070,7 @@ fts_alloc(sp, name, namelen) } static void -fts_lfree(head) - FTSENT *head; +fts_lfree(FTSENT *head) { FTSENT *p; @@ -1100,9 +1088,7 @@ fts_lfree(head) * plus 256 bytes so don't realloc the path 2 bytes at a time. */ static int -fts_palloc(sp, more) - FTS *sp; - size_t more; +fts_palloc(FTS *sp, size_t more) { sp->fts_pathlen += more + 256; @@ -1127,9 +1113,7 @@ fts_palloc(sp, more) * already returned. */ static void -fts_padjust(sp, head) - FTS *sp; - FTSENT *head; +fts_padjust(FTS *sp, FTSENT *head) { FTSENT *p; char *addr = sp->fts_path; @@ -1153,8 +1137,7 @@ fts_padjust(sp, head) } static size_t -fts_maxarglen(argv) - char * const *argv; +fts_maxarglen(char * const *argv) { size_t len, max; @@ -1170,11 +1153,7 @@ fts_maxarglen(argv) * Assumes p->fts_dev and p->fts_ino are filled in. */ static int -fts_safe_changedir(sp, p, fd, path) - FTS *sp; - FTSENT *p; - int fd; - char *path; +fts_safe_changedir(FTS *sp, FTSENT *p, int fd, char *path) { int ret, oerrno, newfd; struct stat sb; diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c index 1f4d7e9fb299..93a82c2db324 100644 --- a/lib/libc/gen/getgrent.c +++ b/lib/libc/gen/getgrent.c @@ -1238,7 +1238,7 @@ compat_setgrent(void *retval, void *mdata, va_list ap) int rv, stayopen; #define set_setent(x, y) do { \ - int i; \ + unsigned int i; \ \ for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \ x[i].mdata = (void *)y; \ @@ -1308,7 +1308,7 @@ compat_group(void *retval, void *mdata, va_list ap) int rv, stayopen, *errnop; #define set_lookup_type(x, y) do { \ - int i; \ + unsigned int i; \ \ for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \ x[i].mdata = (void *)y; \ diff --git a/lib/libc/gen/getloadavg.c b/lib/libc/gen/getloadavg.c index 127d3e8de094..9c06d0a4d986 100644 --- a/lib/libc/gen/getloadavg.c +++ b/lib/libc/gen/getloadavg.c @@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$"); * Return number of samples retrieved, or -1 on error. */ int -getloadavg(loadavg, nelem) - double loadavg[]; - int nelem; +getloadavg(double loadavg[], int nelem) { struct loadavg loadinfo; int i, mib[2]; diff --git a/lib/libc/gen/getmntinfo.c b/lib/libc/gen/getmntinfo.c index 2b532f642c8a..99f82aa8fc61 100644 --- a/lib/libc/gen/getmntinfo.c +++ b/lib/libc/gen/getmntinfo.c @@ -42,9 +42,7 @@ __FBSDID("$FreeBSD$"); * Return information about mounted filesystems. */ int -getmntinfo(mntbufp, flags) - struct statfs **mntbufp; - int flags; +getmntinfo(struct statfs **mntbufp, int flags) { static struct statfs *mntbuf; static int mntsize; diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 09a624785a15..6546f587ae19 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -1607,7 +1607,8 @@ compat_redispatch(struct compat_state *st, enum nss_lookup_type how, { NULL, NULL, NULL } }; void *discard; - int rv, e, i; + int rv, e; + unsigned int i; for (i = 0; i < sizeof(dtab)/sizeof(dtab[0]) - 1; i++) dtab[i].mdata = (void *)lookup_how; @@ -1702,7 +1703,7 @@ compat_setpwent(void *retval, void *mdata, va_list ap) int rv, stayopen; #define set_setent(x, y) do { \ - int i; \ + unsigned int i; \ \ for (i = 0; i < (sizeof(x)/sizeof(x[0])) - 1; i++) \ x[i].mdata = (void *)y; \ diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c index ec878c5bebc5..88254cd99c30 100644 --- a/lib/libc/gen/nlist.c +++ b/lib/libc/gen/nlist.c @@ -63,9 +63,7 @@ int __aout_fdnlist(int, struct nlist *); int __elf_fdnlist(int, struct nlist *); int -nlist(name, list) - const char *name; - struct nlist *list; +nlist(const char *name, struct nlist *list) { int fd, n; @@ -89,11 +87,10 @@ static struct nlist_handlers { }; int -__fdnlist(fd, list) - int fd; - struct nlist *list; +__fdnlist(int fd, struct nlist *list) { - int n = -1, i; + int n = -1; + unsigned int i; for (i = 0; i < sizeof(nlist_fn) / sizeof(nlist_fn[0]); i++) { n = (nlist_fn[i].fn)(fd, list); @@ -107,9 +104,7 @@ __fdnlist(fd, list) #ifdef _NLIST_DO_AOUT int -__aout_fdnlist(fd, list) - int fd; - struct nlist *list; +__aout_fdnlist(int fd, struct nlist *list) { struct nlist *p, *symtab; caddr_t strtab, a_out_mmap; @@ -235,9 +230,7 @@ __elf_is_okay__(Elf_Ehdr *ehdr) } int -__elf_fdnlist(fd, list) - int fd; - struct nlist *list; +__elf_fdnlist(int fd, struct nlist *list) { struct nlist *p; Elf_Off symoff = 0, symstroff = 0; @@ -377,11 +370,7 @@ __elf_fdnlist(fd, list) * n_value and n_type members. */ static void -elf_sym_to_nlist(nl, s, shdr, shnum) - struct nlist *nl; - Elf_Sym *s; - Elf_Shdr *shdr; - int shnum; +elf_sym_to_nlist(struct nlist *nl, Elf_Sym *s, Elf_Shdr *shdr, int shnum) { nl->n_value = s->st_value; diff --git a/lib/libc/gen/strtofflags.c b/lib/libc/gen/strtofflags.c index 55e99451b13d..dba9cd24fb65 100644 --- a/lib/libc/gen/strtofflags.c +++ b/lib/libc/gen/strtofflags.c @@ -94,14 +94,13 @@ static struct { * are set, return the empty string. */ char * -fflagstostr(flags) - u_long flags; +fflagstostr(u_long flags) { char *string; const char *sp; char *dp; u_long setflags; - int i; + u_int i; if ((string = (char *)malloc(nmappings * (longestflaglen + 1))) == NULL) return (NULL); @@ -128,9 +127,7 @@ fflagstostr(flags) * to the offending token. */ int -strtofflags(stringp, setp, clrp) - char **stringp; - u_long *setp, *clrp; +strtofflags(char **stringp, u_long *setp, u_long *clrp) { char *string, *p; int i; diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c index 1f56bc2c3617..b17a18fc3836 100644 --- a/lib/libc/gmon/gmon.c +++ b/lib/libc/gmon/gmon.c @@ -70,9 +70,7 @@ void moncontrol(int); static int hertz(void); void -monstartup(lowpc, highpc) - u_long lowpc; - u_long highpc; +monstartup(u_long lowpc, u_long highpc) { int o; char *cp; @@ -218,8 +216,7 @@ _mcleanup(void) * all the data structures are ready. */ void -moncontrol(mode) - int mode; +moncontrol(int mode) { struct gmonparam *p = &_gmonparam; @@ -239,7 +236,7 @@ moncontrol(mode) * if something goes wrong, we return 0, an impossible hertz. */ static int -hertz() +hertz(void) { struct itimerval tim; diff --git a/lib/libc/stdlib/heapsort.c b/lib/libc/stdlib/heapsort.c index 673a6a17e322..16c1bfe15155 100644 --- a/lib/libc/stdlib/heapsort.c +++ b/lib/libc/stdlib/heapsort.c @@ -147,16 +147,11 @@ typedef DECLARE_BLOCK(int, heapsort_block, const void *, const void *); */ #ifdef I_AM_HEAPSORT_B int -heapsort_b(vbase, nmemb, size, compar) - void *vbase; - size_t nmemb, size; - heapsort_block compar; +heapsort_b(void *vbase, size_t nmemb, size_t size, heapsort_block compar) #else int -heapsort(vbase, nmemb, size, compar) - void *vbase; - size_t nmemb, size; - int (*compar)(const void *, const void *); +heapsort(void *vbase, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)) #endif { size_t cnt, i, j, l; diff --git a/lib/libc/stdlib/merge.c b/lib/libc/stdlib/merge.c index 6b368c34f21e..17f07eb01816 100644 --- a/lib/libc/stdlib/merge.c +++ b/lib/libc/stdlib/merge.c @@ -104,14 +104,10 @@ static void insertionsort(u_char *, size_t, size_t, cmp_t); */ int #ifdef I_AM_MERGESORT_B -mergesort_b(base, nmemb, size, cmp) +mergesort_b(void *base, size_t nmemb, size_t size, cmp_t cmp) #else -mergesort(base, nmemb, size, cmp) +mergesort(void *base, size_t nmemb, size_t size, cmp_t cmp) #endif - void *base; - size_t nmemb; - size_t size; - cmp_t cmp; { size_t i; int sense; @@ -271,10 +267,7 @@ COPY: b = t; * is defined. Otherwise simple pairwise merging is used.) */ void -setup(list1, list2, n, size, cmp) - size_t n, size; - u_char *list1, *list2; - cmp_t cmp; +setup(u_char *list1, u_char *list2, size_t n, size_t size, cmp_t cmp) { int i, length, size2, tmp, sense; u_char *f1, *f2, *s, *l2, *last, *p2; @@ -345,10 +338,7 @@ setup(list1, list2, n, size, cmp) * last 4 elements. */ static void -insertionsort(a, n, size, cmp) - u_char *a; - size_t n, size; - cmp_t cmp; +insertionsort(u_char *a, size_t n, size_t size, cmp_t cmp) { u_char *ai, *s, *t, *u, tmp; int i; diff --git a/lib/libc/stdlib/radixsort.c b/lib/libc/stdlib/radixsort.c index 8310e6dea16c..205f7765a444 100644 --- a/lib/libc/stdlib/radixsort.c +++ b/lib/libc/stdlib/radixsort.c @@ -88,10 +88,7 @@ static void r_sort_b(const u_char **, const u_char **, int, int, } int -radixsort(a, n, tab, endch) - const u_char **a, *tab; - int n; - u_int endch; +radixsort(const u_char **a, int n, const u_char *tab, u_int endch) { const u_char *tr; int c; @@ -103,10 +100,7 @@ radixsort(a, n, tab, endch) } int -sradixsort(a, n, tab, endch) - const u_char **a, *tab; - int n; - u_int endch; +sradixsort(const u_char **a, int n, const u_char *tab, u_int endch) { const u_char *tr, **ta; int c; @@ -131,11 +125,7 @@ sradixsort(a, n, tab, endch) /* Unstable, in-place sort. */ static void -r_sort_a(a, n, i, tr, endch) - const u_char **a; - int n, i; - const u_char *tr; - u_int endch; +r_sort_a(const u_char **a, int n, int i, const u_char *tr, u_int endch) { static int count[256], nc, bmin; int c; @@ -233,11 +223,8 @@ r_sort_a(a, n, i, tr, endch) /* Stable sort, requiring additional memory. */ static void -r_sort_b(a, ta, n, i, tr, endch) - const u_char **a, **ta; - int n, i; - const u_char *tr; - u_int endch; +r_sort_b(const u_char **a, const u_char **ta, int n, int i, const u_char *tr, + u_int endch) { static int count[256], nc, bmin; int c; @@ -304,12 +291,9 @@ r_sort_b(a, ta, n, i, tr, endch) } } +/* insertion sort */ static inline void -simplesort(a, n, b, tr, endch) /* insertion sort */ - const u_char **a; - int n, b; - const u_char *tr; - u_int endch; +simplesort(const u_char **a, int n, int b, const u_char *tr, u_int endch) { u_char ch; const u_char **ak, **ai, *s, *t; diff --git a/lib/libc/sys/setuid.2 b/lib/libc/sys/setuid.2 index 4c7d5ad0c67a..54d89bcc7464 100644 --- a/lib/libc/sys/setuid.2 +++ b/lib/libc/sys/setuid.2 @@ -28,7 +28,7 @@ .\" @(#)setuid.2 8.1 (Berkeley) 6/4/93 .\" $FreeBSD$ .\" -.Dd June 4, 1993 +.Dd September 13, 2015 .Dt SETUID 2 .Os .Sh NAME @@ -178,15 +178,10 @@ pseudocode(void) int fd; /* ... */ - fd = open("/path/to/sensitive/data", O_RDWR); + fd = open("/path/to/sensitive/data", O_RDWR | O_CLOEXEC); if (fd == -1) err(1, "open"); - /* - * Set close-on-exec flag; see fcntl(2) for more information. - */ - if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) - err(1, "fcntl(F_SETFD)"); /* ... */ execve(path, argv, environ); } |
