-/* $OpenBSD: utils.c,v 1.49 2021/10/24 21:24:21 deraadt Exp $ */
+/* $OpenBSD: utils.c,v 1.50 2021/11/28 19:28:41 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
* SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/time.h>
#include "extern.h"
+#define _MAXBSIZE (64 * 1024)
+
int copy_overwrite(void);
int
static char *zeroes;
struct stat to_stat, *fs;
int from_fd, rcount, rval, to_fd, wcount;
+ const size_t buflen = _MAXBSIZE;
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
char *p;
#endif
if (!buf) {
- buf = malloc(MAXBSIZE);
+ buf = malloc(buflen);
if (!buf)
err(1, "malloc");
}
if (!zeroes) {
- zeroes = calloc(1, MAXBSIZE);
+ zeroes = calloc(1, buflen);
if (!zeroes)
err(1, "calloc");
}
struct stat tosb;
if (!fstat(to_fd, &tosb) && S_ISREG(tosb.st_mode))
skipholes = 1;
- while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
+ while ((rcount = read(from_fd, buf, buflen)) > 0) {
if (skipholes && memcmp(buf, zeroes, rcount) == 0)
wcount = lseek(to_fd, rcount, SEEK_CUR) == -1 ? -1 : rcount;
else
-/* $OpenBSD: cp.c,v 1.9 2021/10/24 21:24:21 deraadt Exp $ */
+/* $OpenBSD: cp.c,v 1.10 2021/11/28 19:28:41 deraadt Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
}
-/* $OpenBSD: cp.c,v 1.9 2021/10/24 21:24:21 deraadt Exp $ */
+/* $OpenBSD: cp.c,v 1.10 2021/11/28 19:28:41 deraadt Exp $ */
/* $NetBSD: utils.c,v 1.6 1997/02/26 14:40:51 cgd Exp $ */
/*-
* SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <unistd.h>
#include <limits.h>
+#define _MAXBSIZE (64 * 1024)
+
static int
copy_file(FTSENT *entp, int dne)
{
static char *zeroes;
struct stat *fs;
int ch, checkch, from_fd, rcount, rval, to_fd, wcount;
+ const size_t buflen = _MAXBSIZE;
#ifdef VM_AND_BUFFER_CACHE_SYNCHRONIZED
char *p;
#endif
if (!buf) {
- buf = malloc(MAXBSIZE);
+ buf = malloc(buflen);
if (!buf)
err(1, "malloc");
}
if (!zeroes) {
- zeroes = calloc(1, MAXBSIZE);
+ zeroes = calloc(1, buflen);
if (!zeroes)
err(1, "calloc");
}
struct stat tosb;
if (!fstat(to_fd, &tosb) && S_ISREG(tosb.st_mode))
skipholes = 1;
- while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
+ while ((rcount = read(from_fd, buf, buflen)) > 0) {
if (skipholes && memcmp(buf, zeroes, rcount) == 0)
wcount = lseek(to_fd, rcount, SEEK_CUR) == -1 ? -1 : rcount;
else
-/* $OpenBSD: cdio.c,v 1.82 2021/10/24 21:24:16 deraadt Exp $ */
+/* $OpenBSD: cdio.c,v 1.83 2021/11/28 19:28:41 deraadt Exp $ */
/* Copyright (c) 1995 Serge V. Vakulenko
* All rights reserved.
* $FreeBSD: cdcontrol.c,v 1.13 1996/06/25 21:01:27 ache Exp $
*/
-#include <sys/param.h> /* isset */
+#include <sys/types.h>
#include <sys/cdio.h>
#include <sys/ioctl.h>
#include <sys/queue.h>
warnx("Can't determine media type");
return (0);
}
- if (isset(mediacap, MMC_FEATURE_CDRW_WRITE) == 0 &&
+ if (cdio_isset(mediacap, MMC_FEATURE_CDRW_WRITE) == 0 &&
get_media_type() != MEDIATYPE_CDRW) {
warnx("The media doesn't support blanking");
return (0);
exit(1);
if (get_media_capabilities(mediacap, 1) == -1)
errx(1, "Can't determine media type");
- if (isset(mediacap, MMC_FEATURE_CD_TAO) == 0)
+ if (cdio_isset(mediacap, MMC_FEATURE_CD_TAO) == 0)
errx(1, "The media can't be written in TAO mode");
get_disc_size(&availblk);
-/* $OpenBSD: extern.h,v 1.16 2021/01/18 00:44:00 mortimer Exp $ */
+/* $OpenBSD: extern.h,v 1.17 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2002 Marc Espie.
*
#include <sys/queue.h>
+#define cdio_isset(a,i) ((a)[(i)>>3] & (1<<((i)&(NBBY-1))))
+#define cdio_setbit(a,i) ((a)[(i)>>3] |= 1<<((i)&(NBBY-1)))
+
struct cd_toc_entry;
struct track_info {
off_t sz;
-/* $OpenBSD: mmc.c,v 1.32 2020/09/01 17:20:02 krw Exp $ */
+/* $OpenBSD: mmc.c,v 1.33 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2006 Michael Coulter <mjc@openbsd.org>
*
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#include <sys/types.h>
#include <sys/limits.h>
#include <sys/time.h>
-#include <sys/types.h>
#include <sys/scsiio.h>
-#include <sys/param.h> /* setbit, isset */
#include <scsi/cd.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_disk.h>
"" );
}
}
- setbit(cap, feature);
+ cdio_setbit(cap, feature);
}
return (0);
memset(&scr, 0, sizeof(scr));
scr.cmd[0] = SET_CD_SPEED;
- scr.cmd[1] = (isset(mediacap, MMC_FEATURE_CDRW_CAV)) != 0;
+ scr.cmd[1] = (cdio_isset(mediacap, MMC_FEATURE_CDRW_CAV)) != 0;
*(u_int16_t *)(scr.cmd + 2) = htobe16(DRIVE_SPEED_OPTIMAL);
*(u_int16_t *)(scr.cmd + 4) = htobe16(wspeed);
-/* $OpenBSD: remote.c,v 1.33 2019/06/28 13:35:00 deraadt Exp $ */
+/* $OpenBSD: remote.c,v 1.34 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include "remote.h"
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define _MAXBSIZE (64 * 1024)
struct cvs_resp *
cvs_remote_get_response_info(const char *response)
cvs_remote_receive_file(int fd, size_t len)
{
FILE *in;
- char data[MAXBSIZE];
+ char data[_MAXBSIZE];
size_t nread, nleft, toread;
if (cvs_server_active)
nleft = len;
while (nleft > 0) {
- toread = MINIMUM(nleft, MAXBSIZE);
+ toread = MINIMUM(nleft, sizeof data);
nread = fread(data, sizeof(char), toread, in);
if (nread == 0)
size_t ret, rw;
off_t total;
struct stat st;
- char buf[18], data[MAXBSIZE];
+ char buf[18], data[_MAXBSIZE];
if (cvs_server_active)
out = stdout;
fatal("cvs_remote_send_file: fdopen %s", strerror(errno));
total = 0;
- while ((ret = fread(data, sizeof(char), MAXBSIZE, in)) != 0) {
+ while ((ret = fread(data, sizeof(char), sizeof data, in)) != 0) {
rw = fwrite(data, sizeof(char), ret, out);
if (rw != ret)
fatal("failed to write %zu bytes", ret);
-/* $OpenBSD: rcs.c,v 1.88 2019/01/09 17:57:05 joris Exp $ */
+/* $OpenBSD: rcs.c,v 1.89 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include "rcsutil.h"
#include "xmalloc.h"
+#define _MAXBSIZE (64 * 1024)
+
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
/* invalid characters in RCS states */
return (-1);
}
- buf = xmalloc(MAXBSIZE);
- while ((nread = fread(buf, sizeof(char), MAXBSIZE, src)) != 0) {
+ buf = xmalloc(_MAXBSIZE);
+ while ((nread = fread(buf, sizeof(char), _MAXBSIZE, src)) != 0) {
if (ferror(src)) {
warnx("failed to read `%s'", from);
(void)unlink(to);
-/* $OpenBSD: copy.c,v 1.2 2021/10/24 21:24:17 deraadt Exp $ */
+/* $OpenBSD: copy.c,v 1.3 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 2021 Claudio Jeker <claudio@openbsd.org>
*
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <err.h>
#include <fcntl.h>
#include "extern.h"
+#define _MAXBSIZE (64 * 1024)
+
/*
* Return true if all bytes in buffer are zero.
* A buffer of zero lenght is also considered a zero buffer.
static int
copy_internal(int fromfd, int tofd)
{
- char buf[MAXBSIZE];
+ char buf[_MAXBSIZE];
ssize_t r, w;
while ((r = read(fromfd, buf, sizeof(buf))) > 0) {
-/* $OpenBSD: split.c,v 1.22 2021/10/24 21:24:17 deraadt Exp $ */
+/* $OpenBSD: split.c,v 1.23 2021/11/28 19:28:42 deraadt Exp $ */
/* $NetBSD: split.c,v 1.5 1995/08/31 22:22:05 jtc Exp $ */
/*
* SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
#include <sys/types.h>
#include <ctype.h>
#include <unistd.h>
#include <regex.h>
+#define _MAXBSIZE (64 * 1024)
+
#define DEFLINE 1000 /* Default num lines per file. */
ssize_t bytecnt; /* Byte count to split on. */
long numlines; /* Line count to split on. */
int file_open; /* If a file open. */
int ifd = -1, ofd = -1; /* Input/output file descriptors. */
-char bfr[MAXBSIZE]; /* I/O buffer. */
+char bfr[_MAXBSIZE]; /* I/O buffer. */
char fname[PATH_MAX]; /* File name prefix. */
regex_t rgx;
int pflag;
char *C;
for (bcnt = 0;;)
- switch ((len = read(ifd, bfr, MAXBSIZE))) {
+ switch ((len = read(ifd, bfr, sizeof(bfr)))) {
case 0:
exit(0);
case -1:
-/* $OpenBSD: wc.c,v 1.28 2021/11/16 23:34:24 cheloha Exp $ */
+/* $OpenBSD: wc.c,v 1.29 2021/11/28 19:28:42 deraadt Exp $ */
/*
* Copyright (c) 1980, 1987, 1991, 1993
* SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
#include <sys/stat.h>
#include <fcntl.h>
#include <wchar.h>
#include <wctype.h>
+#define _MAXBSIZE (64 * 1024)
+
int64_t tlinect, twordct, tcharct;
int doline, doword, dochar, humanchar, multibyte;
int rval;
}
if (!doword && !multibyte) {
- if (bufsz < MAXBSIZE &&
- (buf = realloc(buf, MAXBSIZE)) == NULL)
+ if (bufsz < _MAXBSIZE &&
+ (buf = realloc(buf, _MAXBSIZE)) == NULL)
err(1, NULL);
/*
* Line counting is split out because it's a lot
* the word count requires some logic.
*/
if (doline) {
- while ((len = read(fd, buf, MAXBSIZE)) > 0) {
+ while ((len = read(fd, buf, _MAXBSIZE)) > 0) {
charct += len;
for (C = buf; len--; ++C)
if (*C == '\n')
|| ifmt == S_IFDIR) {
charct = sbuf.st_size;
} else {
- while ((len = read(fd, buf, MAXBSIZE)) > 0)
+ while ((len = read(fd, buf, _MAXBSIZE)) > 0)
charct += len;
if (len == -1) {
warn("%s", file);
-/* $OpenBSD: xinstall.c,v 1.75 2021/10/24 21:24:18 deraadt Exp $ */
+/* $OpenBSD: xinstall.c,v 1.76 2021/11/28 19:28:42 deraadt Exp $ */
/* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */
/*
* SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <sys/wait.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include "pathnames.h"
+#define _MAXBSIZE (64 * 1024)
+
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define DIRECTORY 0x01 /* Tell install it's a directory. */
{
ssize_t nr, nw;
int serrno;
- char *p, buf[MAXBSIZE];
+ char *p, buf[_MAXBSIZE];
if (size == 0)
return;
-/* $OpenBSD: pwd_mkdb.c,v 1.58 2021/10/24 21:24:19 deraadt Exp $ */
+/* $OpenBSD: pwd_mkdb.c,v 1.59 2021/11/28 19:28:42 deraadt Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
* SUCH DAMAGE.
*/
-#include <sys/param.h> /* MAXBSIZE */
+#include <sys/types.h>
#include <sys/stat.h>
#include <db.h>
#include <util.h>
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
+#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
+#define _MAXBSIZE (64 * 1024)
#define INSECURE 1
#define SECURE 2
uid_t olduid;
gid_t shadow;
int ch, tfd, makeold, secureonly, flags, checkonly;
- char *username, buf[MAX(PATH_MAX, LINE_MAX * 2)];
+ char *username, buf[MAXIMUM(PATH_MAX, LINE_MAX * 2)];
flags = checkonly = makeold = secureonly = 0;
username = NULL;
void
cp(char *from, char *to, mode_t mode)
{
- static char buf[MAXBSIZE];
+ static char buf[_MAXBSIZE];
int from_fd, rcount, to_fd, wcount;
if ((from_fd = open(from, O_RDONLY)) == -1)
fatal("%s", from);
if ((to_fd = open(to, O_WRONLY|O_CREAT|O_EXCL, mode)) == -1)
fatal("%s", to);
- while ((rcount = read(from_fd, buf, MAXBSIZE)) > 0) {
+ while ((rcount = read(from_fd, buf, sizeof buf)) > 0) {
wcount = write(to_fd, buf, rcount);
if (rcount != wcount || wcount == -1)
fatal("%s to %s", from, to);