mirror of
https://github.com/openbsd/src.git
synced 2025-01-03 06:45:37 -08:00
SIZE_MAX is standard, we should be using it in preference to the
obsolete SIZE_T_MAX. OK miod@ beck@
This commit is contained in:
parent
f7edeccc84
commit
4239b8225f
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: getusershell.c,v 1.14 2014/09/15 06:15:48 guenther Exp $ */
|
||||
/* $OpenBSD: getusershell.c,v 1.15 2015/02/06 23:21:58 millert Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1985, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -33,6 +33,7 @@
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <paths.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
@ -101,7 +102,7 @@ initshells(void)
|
||||
(void)fclose(fp);
|
||||
return (okshells);
|
||||
}
|
||||
if (statb.st_size > SIZE_T_MAX) {
|
||||
if (statb.st_size > SIZE_MAX) {
|
||||
(void)fclose(fp);
|
||||
return (okshells);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: nlist.c,v 1.58 2015/01/16 16:48:51 deraadt Exp $ */
|
||||
/* $OpenBSD: nlist.c,v 1.59 2015/02/06 23:21:58 millert Exp $ */
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
@ -34,11 +34,11 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <a.out.h> /* pulls in nlist.h */
|
||||
|
||||
#ifdef _NLIST_DO_ELF
|
||||
@ -111,7 +111,7 @@ __fdnlist(int fd, struct nlist *list)
|
||||
shdr_size = ehdr.e_shentsize * ehdr.e_shnum;
|
||||
|
||||
/* Make sure it's not too big to mmap */
|
||||
if (shdr_size > SIZE_T_MAX) {
|
||||
if (shdr_size > SIZE_MAX) {
|
||||
errno = EFBIG;
|
||||
return (-1);
|
||||
}
|
||||
@ -154,7 +154,7 @@ __fdnlist(int fd, struct nlist *list)
|
||||
|
||||
/* Check for files too large to mmap. */
|
||||
/* XXX is this really possible? */
|
||||
if (symstrsize > SIZE_T_MAX) {
|
||||
if (symstrsize > SIZE_MAX) {
|
||||
errno = EFBIG;
|
||||
return (-1);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: getdelim.c,v 1.2 2014/10/16 17:31:51 millert Exp $ */
|
||||
/* $OpenBSD: getdelim.c,v 1.3 2015/02/06 23:21:58 millert Exp $ */
|
||||
/* $NetBSD: getdelim.c,v 1.13 2011/07/22 23:12:30 joerg Exp $ */
|
||||
|
||||
/*
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -96,7 +97,7 @@ getdelim(char **__restrict buf, size_t *__restrict buflen,
|
||||
newlen |= newlen >> 4;
|
||||
newlen |= newlen >> 8;
|
||||
newlen |= newlen >> 16;
|
||||
#if SIZE_T_MAX > 0xffffffffU
|
||||
#if SIZE_MAX > 0xffffffffU
|
||||
newlen |= newlen >> 32;
|
||||
#endif
|
||||
newlen++;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: readline.c,v 1.13 2015/01/13 08:33:12 reyk Exp $ */
|
||||
/* $OpenBSD: readline.c,v 1.14 2015/02/06 23:21:58 millert Exp $ */
|
||||
/* $NetBSD: readline.c,v 1.91 2010/08/28 15:44:59 christos Exp $ */
|
||||
|
||||
/*-
|
||||
@ -34,6 +34,7 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
@ -2133,7 +2134,7 @@ rl_completion_matches(const char *str, rl_compentry_func_t *fun)
|
||||
}
|
||||
qsort(&list[1], len - 1, sizeof(*list),
|
||||
(int (*)(const void *, const void *)) strcmp);
|
||||
min = SIZE_T_MAX;
|
||||
min = SIZE_MAX;
|
||||
for (i = 1, a = list[i]; i < len - 1; i++, a = b) {
|
||||
b = list[i + 1];
|
||||
for (j = 0; a[j] && a[j] == b[j]; j++)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: fuse_opt.c,v 1.11 2014/10/08 04:50:10 deraadt Exp $ */
|
||||
/* $OpenBSD: fuse_opt.c,v 1.12 2015/02/06 23:21:58 millert Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2013 Sylvestre Gallon <ccna.syl@gmail.com>
|
||||
* Copyright (c) 2013 Stefan Sperling <stsp@openbsd.org>
|
||||
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -174,7 +175,7 @@ fuse_opt_add_opt_escaped(char **opts, const char *opt)
|
||||
|
||||
while (*s) {
|
||||
/* malloc(size + escaped) overflow check */
|
||||
if (size >= (SIZE_T_MAX / 2))
|
||||
if (size >= (SIZE_MAX / 2))
|
||||
return (-1);
|
||||
|
||||
if (*s == ',' || *s == '\\')
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: monitor.c,v 1.21 2014/08/25 07:50:25 doug Exp $ */
|
||||
/* $OpenBSD: monitor.c,v 1.22 2015/02/06 23:21:58 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Moritz Jodeit <moritz@openbsd.org>
|
||||
@ -23,11 +23,11 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <paths.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -266,7 +266,7 @@ handle_cmds(void)
|
||||
debugmsg("CMD_USER received");
|
||||
|
||||
recv_data(fd_slave, &len, sizeof(len));
|
||||
if (len == SIZE_T_MAX)
|
||||
if (len == SIZE_MAX)
|
||||
fatalx("monitor received invalid user length");
|
||||
if ((name = malloc(len + 1)) == NULL)
|
||||
fatalx("malloc: %m");
|
||||
@ -281,7 +281,7 @@ handle_cmds(void)
|
||||
debugmsg("CMD_PASS received");
|
||||
|
||||
recv_data(fd_slave, &len, sizeof(len));
|
||||
if (len == SIZE_T_MAX)
|
||||
if (len == SIZE_MAX)
|
||||
fatalx("monitor received invalid pass length");
|
||||
if ((pw = malloc(len + 1)) == NULL)
|
||||
fatalx("malloc: %m");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: dbtest.c,v 1.12 2009/10/27 23:59:32 deraadt Exp $ */
|
||||
/* $OpenBSD: dbtest.c,v 1.13 2015/02/06 23:21:58 millert Exp $ */
|
||||
/* $NetBSD: dbtest.c,v 1.8 1996/05/03 21:57:48 cgd Exp $ */
|
||||
|
||||
/*-
|
||||
@ -36,7 +36,7 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -685,10 +685,8 @@ rfile(name, lenp)
|
||||
if ((fd = open(name, O_RDONLY, 0)) < 0 ||
|
||||
fstat(fd, &sb))
|
||||
dberr("%s: %s\n", name, strerror(errno));
|
||||
#ifdef NOT_PORTABLE
|
||||
if (sb.st_size > (off_t)SIZE_T_MAX)
|
||||
if (sb.st_size > (off_t)SIZE_MAX)
|
||||
dberr("%s: %s\n", name, strerror(E2BIG));
|
||||
#endif
|
||||
if ((p = (void *)malloc((u_int)sb.st_size)) == NULL)
|
||||
dberr("%s", strerror(errno));
|
||||
(void)read(fd, p, (int)sb.st_size);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mmap_size.c,v 1.2 2006/03/14 09:31:51 mickey Exp $ */
|
||||
/* $OpenBSD: mmap_size.c,v 1.3 2015/02/06 23:21:58 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Public domain. 2005, Otto Moerbeek <otto@drijf.net>
|
||||
@ -7,9 +7,9 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void
|
||||
f(size_t sz)
|
||||
@ -37,7 +37,7 @@ main()
|
||||
for (i = 0; i < 0x2000; i += 0x100) {
|
||||
f(i);
|
||||
f(-i);
|
||||
f(SIZE_T_MAX/2 - 0x1000);
|
||||
f(SIZE_MAX/2 - 0x1000);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: regular.c,v 1.11 2015/01/16 06:40:06 deraadt Exp $ */
|
||||
/* $OpenBSD: regular.c,v 1.12 2015/02/06 23:21:59 millert Exp $ */
|
||||
/* $NetBSD: regular.c,v 1.2 1995/09/08 03:22:59 tls Exp $ */
|
||||
|
||||
/*-
|
||||
@ -34,7 +34,7 @@
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -62,7 +62,7 @@ c_regular(int fd1, char *file1, off_t skip1, off_t len1,
|
||||
len2 -= skip2;
|
||||
|
||||
length = MINIMUM(len1, len2);
|
||||
if (length > SIZE_T_MAX) {
|
||||
if (length > SIZE_MAX) {
|
||||
mmap_failed:
|
||||
c_special(fd1, file1, skip1, fd2, file2, skip2);
|
||||
return;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: mmfile.c,v 1.16 2015/01/16 06:40:08 deraadt Exp $ */
|
||||
/* $OpenBSD: mmfile.c,v 1.17 2015/02/06 23:21:59 millert Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
|
||||
@ -54,7 +54,7 @@ mmopen(char *fn, char *mode)
|
||||
goto ouch1;
|
||||
if (fstat(mmf->fd, &st) == -1)
|
||||
goto ouch2;
|
||||
if (st.st_size > SIZE_T_MAX) /* too big to mmap */
|
||||
if (st.st_size > SIZE_MAX) /* too big to mmap */
|
||||
goto ouch2;
|
||||
if (!S_ISREG(st.st_mode)) /* only mmap regular files */
|
||||
goto ouch2;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: look.c,v 1.15 2014/05/20 01:25:23 guenther Exp $ */
|
||||
/* $OpenBSD: look.c,v 1.16 2015/02/06 23:21:59 millert Exp $ */
|
||||
/* $NetBSD: look.c,v 1.7 1995/08/31 22:41:02 jtc Exp $ */
|
||||
|
||||
/*-
|
||||
@ -48,7 +48,7 @@
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -126,7 +126,7 @@ main(int argc, char *argv[])
|
||||
|
||||
if ((fd = open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
|
||||
err(2, "%s", file);
|
||||
if (sb.st_size > SIZE_T_MAX)
|
||||
if (sb.st_size > SIZE_MAX)
|
||||
errc(2, EFBIG, "%s", file);
|
||||
if ((front = mmap(NULL,
|
||||
(size_t)sb.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0)) == MAP_FAILED)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: elf.c,v 1.25 2015/01/19 20:25:36 miod Exp $ */
|
||||
/* $OpenBSD: elf.c,v 1.26 2015/02/06 23:21:59 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2003 Michael Shalayeff
|
||||
@ -32,10 +32,10 @@
|
||||
#include <elf_abi.h>
|
||||
#include <errno.h>
|
||||
#include <err.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include <ctype.h>
|
||||
#include "elfuncs.h"
|
||||
#include "util.h"
|
||||
@ -454,7 +454,7 @@ elf_symloadx(const char *name, FILE *fp, off_t foff, Elf_Ehdr *eh,
|
||||
for (i = 0; i < eh->e_shnum; i++) {
|
||||
if (!strcmp(shstr + shdr[i].sh_name, strtab)) {
|
||||
*pstabsize = shdr[i].sh_size;
|
||||
if (*pstabsize > SIZE_T_MAX) {
|
||||
if (*pstabsize > SIZE_MAX) {
|
||||
warnx("%s: corrupt file", name);
|
||||
return (1);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: spellprog.c,v 1.9 2015/01/16 06:40:12 deraadt Exp $ */
|
||||
/* $OpenBSD: spellprog.c,v 1.10 2015/02/06 23:21:59 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -73,6 +73,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -283,7 +284,7 @@ main(int argc, char **argv)
|
||||
wlists[i].fd = open(argv[i], O_RDONLY, 0);
|
||||
if (wlists[i].fd == -1 || fstat(wlists[i].fd, &sb) != 0)
|
||||
err(1, "%s", argv[i]);
|
||||
if (sb.st_size > SIZE_T_MAX)
|
||||
if (sb.st_size > SIZE_MAX)
|
||||
errc(1, EFBIG, "%s", argv[i]);
|
||||
wlists[i].front = mmap(NULL, (size_t)sb.st_size, PROT_READ,
|
||||
MAP_PRIVATE, wlists[i].fd, (off_t)0);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: channels.c,v 1.340 2015/01/20 23:14:00 deraadt Exp $ */
|
||||
/* $OpenBSD: channels.c,v 1.341 2015/02/06 23:21:59 millert Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -54,12 +54,12 @@
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <netdb.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
@ -2159,7 +2159,7 @@ channel_prepare_select(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
|
||||
|
||||
nfdset = howmany(n+1, NFDBITS);
|
||||
/* Explicitly test here, because xrealloc isn't always called */
|
||||
if (nfdset && SIZE_T_MAX / nfdset < sizeof(fd_mask))
|
||||
if (nfdset && SIZE_MAX / nfdset < sizeof(fd_mask))
|
||||
fatal("channel_prepare_select: max_fd (%d) is too large", n);
|
||||
sz = nfdset * sizeof(fd_mask);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: monitor.c,v 1.141 2015/01/20 23:14:00 deraadt Exp $ */
|
||||
/* $OpenBSD: monitor.c,v 1.142 2015/02/06 23:21:59 millert Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
* Copyright 2002 Markus Friedl <markus@openbsd.org>
|
||||
@ -42,10 +42,10 @@
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "atomicio.h"
|
||||
#include "xmalloc.h"
|
||||
@ -394,7 +394,7 @@ mm_zalloc(struct mm_master *mm, u_int ncount, u_int size)
|
||||
size_t len = (size_t) size * ncount;
|
||||
void *address;
|
||||
|
||||
if (len == 0 || ncount > SIZE_T_MAX / size)
|
||||
if (len == 0 || ncount > SIZE_MAX / size)
|
||||
fatal("%s: mm_zalloc(%u, %u)", __func__, ncount, size);
|
||||
|
||||
address = mm_malloc(mm, len);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: monitor_mm.c,v 1.20 2015/01/20 23:14:00 deraadt Exp $ */
|
||||
/* $OpenBSD: monitor_mm.c,v 1.21 2015/02/06 23:21:59 millert Exp $ */
|
||||
/*
|
||||
* Copyright 2002 Niels Provos <provos@citi.umich.edu>
|
||||
* All rights reserved.
|
||||
@ -31,9 +31,9 @@
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "ssh.h"
|
||||
@ -168,7 +168,7 @@ mm_malloc(struct mm_master *mm, size_t size)
|
||||
|
||||
if (size == 0)
|
||||
fatal("mm_malloc: try to allocate 0 space");
|
||||
if (size > SIZE_T_MAX - MM_MINSIZE + 1)
|
||||
if (size > SIZE_MAX - MM_MINSIZE + 1)
|
||||
fatal("mm_malloc: size too big");
|
||||
|
||||
size = ((size + (MM_MINSIZE - 1)) / MM_MINSIZE) * MM_MINSIZE;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: xmalloc.c,v 1.30 2015/01/16 06:40:12 deraadt Exp $ */
|
||||
/* $OpenBSD: xmalloc.c,v 1.31 2015/02/06 23:21:59 millert Exp $ */
|
||||
/*
|
||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||
@ -14,10 +14,10 @@
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "xmalloc.h"
|
||||
#include "log.h"
|
||||
@ -42,8 +42,8 @@ xcalloc(size_t nmemb, size_t size)
|
||||
|
||||
if (size == 0 || nmemb == 0)
|
||||
fatal("xcalloc: zero size");
|
||||
if (SIZE_T_MAX / nmemb < size)
|
||||
fatal("xcalloc: nmemb * size > SIZE_T_MAX");
|
||||
if (SIZE_MAX / nmemb < size)
|
||||
fatal("xcalloc: nmemb * size > SIZE_MAX");
|
||||
ptr = calloc(nmemb, size);
|
||||
if (ptr == NULL)
|
||||
fatal("xcalloc: out of memory (allocating %zu bytes)",
|
||||
@ -59,8 +59,8 @@ xrealloc(void *ptr, size_t nmemb, size_t size)
|
||||
|
||||
if (new_size == 0)
|
||||
fatal("xrealloc: zero size");
|
||||
if (SIZE_T_MAX / nmemb < size)
|
||||
fatal("xrealloc: nmemb * size > SIZE_T_MAX");
|
||||
if (SIZE_MAX / nmemb < size)
|
||||
fatal("xrealloc: nmemb * size > SIZE_MAX");
|
||||
if (ptr == NULL)
|
||||
new_ptr = malloc(new_size);
|
||||
else
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: read.c,v 1.14 2009/10/27 23:59:44 deraadt Exp $ */
|
||||
/* $OpenBSD: read.c,v 1.15 2015/02/06 23:21:59 millert Exp $ */
|
||||
/* $NetBSD: read.c,v 1.4 1994/11/23 07:42:07 jtc Exp $ */
|
||||
|
||||
/*-
|
||||
@ -35,10 +35,10 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/limits.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
@ -67,7 +67,7 @@ bytes(FILE *fp, off_t off)
|
||||
int wrap;
|
||||
char *sp;
|
||||
|
||||
if (off > SIZE_T_MAX)
|
||||
if (off > SIZE_MAX)
|
||||
errx(1, "offset too large");
|
||||
|
||||
if ((sp = p = malloc(off)) == NULL)
|
||||
@ -148,7 +148,7 @@ lines(FILE *fp, off_t off)
|
||||
size_t cnt, recno, blen, newsize;
|
||||
char *sp = NULL, *newp = NULL;
|
||||
|
||||
if (off > SIZE_T_MAX)
|
||||
if (off > SIZE_MAX)
|
||||
errx(1, "offset too large");
|
||||
|
||||
if ((lines = calloc(off, sizeof(*lines))) == NULL)
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: pf.c,v 1.9 2015/01/21 21:50:33 deraadt Exp $ */
|
||||
/* $OpenBSD: pf.c,v 1.10 2015/02/06 23:21:59 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012 Joel Knight <joel@openbsd.org>
|
||||
@ -43,11 +43,11 @@
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <event.h>
|
||||
|
||||
#include "snmpd.h"
|
||||
@ -145,7 +145,7 @@ pfr_buf_grow(struct pfr_buffer *b, int minsize)
|
||||
} else {
|
||||
if (minsize == 0)
|
||||
minsize = b->pfrb_msize * 2;
|
||||
if (minsize < 0 || (size_t)minsize >= SIZE_T_MAX / bs) {
|
||||
if (minsize < 0 || (size_t)minsize >= SIZE_MAX / bs) {
|
||||
/* msize overflow */
|
||||
return (-1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user