diff options
| author | 2019-12-16 16:16:22 +0000 | |
|---|---|---|
| committer | 2019-12-16 16:16:22 +0000 | |
| commit | 2fc5abb04c862f358e234358caea4444e15db068 (patch) | |
| tree | 1c77d5b577fef0399be14245b2108ca9c1a8819d /usr.sbin/bind/lib/isc/unix/stdio.c | |
| parent | Need to include message size in the maximum buffer calculation. (diff) | |
| download | wireguard-openbsd-2fc5abb04c862f358e234358caea4444e15db068.tar.xz wireguard-openbsd-2fc5abb04c862f358e234358caea4444e15db068.zip | |
Update to bind-9.10.5-P3, which appears to have been the last ISC version.
We only use this tree to build dig and nslookup. Our previous version
predated edns0 support in those tools, and we want that. This is the worst
code I've looked at in years, with layers and layers of spaghetti abstraction
clearly unfit for reuse, but then reused anyways, and the old ones remain
behind. So this is a 8MB diff.
florian, sthen, and otto tried this merge before but failed.
Diffstat (limited to 'usr.sbin/bind/lib/isc/unix/stdio.c')
| -rw-r--r-- | usr.sbin/bind/lib/isc/unix/stdio.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/usr.sbin/bind/lib/isc/unix/stdio.c b/usr.sbin/bind/lib/isc/unix/stdio.c index 2009588e792..27a6462950f 100644 --- a/usr.sbin/bind/lib/isc/unix/stdio.c +++ b/usr.sbin/bind/lib/isc/unix/stdio.c @@ -1,8 +1,8 @@ /* - * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004, 2007, 2011-2014, 2016 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 2000, 2001 Internet Software Consortium. * - * Permission to use, copy, modify, and distribute this software for any + * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $ISC: stdio.c,v 1.6 2004/03/05 05:11:47 marka Exp $ */ +/* $Id: stdio.c,v 1.2 2019/12/16 16:16:27 deraadt Exp $ */ #include <config.h> @@ -23,6 +23,8 @@ #include <unistd.h> #include <isc/stdio.h> +#include <isc/stat.h> +#include <isc/util.h> #include "errno2result.h" @@ -49,10 +51,14 @@ isc_stdio_close(FILE *f) { } isc_result_t -isc_stdio_seek(FILE *f, long offset, int whence) { +isc_stdio_seek(FILE *f, off_t offset, int whence) { int r; +#ifdef HAVE_FSEEKO + r = fseeko(f, offset, whence); +#else r = fseek(f, offset, whence); +#endif if (r == 0) return (ISC_R_SUCCESS); else @@ -60,6 +66,24 @@ isc_stdio_seek(FILE *f, long offset, int whence) { } isc_result_t +isc_stdio_tell(FILE *f, off_t *offsetp) { + off_t r; + + REQUIRE(offsetp != NULL); + +#ifdef HAVE_FTELLO + r = ftello(f); +#else + r = ftell(f); +#endif + if (r >= 0) { + *offsetp = r; + return (ISC_R_SUCCESS); + } else + return (isc__errno2result(errno)); +} + +isc_result_t isc_stdio_read(void *ptr, size_t size, size_t nmemb, FILE *f, size_t *nret) { isc_result_t result = ISC_R_SUCCESS; size_t r; @@ -104,10 +128,27 @@ isc_stdio_flush(FILE *f) { return (isc__errno2result(errno)); } +/* + * OpenBSD has deprecated ENOTSUP in favor of EOPNOTSUPP. + */ +#if defined(EOPNOTSUPP) && !defined(ENOTSUP) +#define ENOTSUP EOPNOTSUPP +#endif + isc_result_t isc_stdio_sync(FILE *f) { + struct stat buf; int r; + if (fstat(fileno(f), &buf) != 0) + return (isc__errno2result(errno)); + + /* + * Only call fsync() on regular files. + */ + if ((buf.st_mode & S_IFMT) != S_IFREG) + return (ISC_R_SUCCESS); + r = fsync(fileno(f)); if (r == 0) return (ISC_R_SUCCESS); |
