summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormillert@openbsd.org <millert@openbsd.org>2015-02-06 23:21:59 +0000
committerDamien Miller <djm@mindrot.org>2015-02-09 09:28:17 +1100
commitfd36834871d06a03e1ff8d69e41992efa1bbf85f (patch)
tree95390638f8f92dfd017176d558acec1e91a9e3b0
parent1910a286d7771eab84c0b047f31c0a17505236fa (diff)
upstream commit
SIZE_MAX is standard, we should be using it in preference to the obsolete SIZE_T_MAX. OK miod@ beck@
-rw-r--r--channels.c6
-rw-r--r--monitor.c6
-rw-r--r--monitor_mm.c6
-rw-r--r--xmalloc.c12
4 files changed, 15 insertions, 15 deletions
diff --git a/channels.c b/channels.c
index 2fedaf89d..86c454ab5 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.340 2015/01/20 23:14:00 deraadt Exp $ */ 1/* $OpenBSD: channels.c,v 1.341 2015/02/06 23:21:59 millert Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -57,12 +57,12 @@
57#include <errno.h> 57#include <errno.h>
58#include <fcntl.h> 58#include <fcntl.h>
59#include <netdb.h> 59#include <netdb.h>
60#include <stdint.h>
60#include <stdio.h> 61#include <stdio.h>
61#include <stdlib.h> 62#include <stdlib.h>
62#include <string.h> 63#include <string.h>
63#include <termios.h> 64#include <termios.h>
64#include <unistd.h> 65#include <unistd.h>
65#include <limits.h>
66#include <stdarg.h> 66#include <stdarg.h>
67 67
68#include "openbsd-compat/sys-queue.h" 68#include "openbsd-compat/sys-queue.h"
@@ -2184,7 +2184,7 @@ channel_prepare_select(fd_set **readsetp, fd_set **writesetp, int *maxfdp,
2184 2184
2185 nfdset = howmany(n+1, NFDBITS); 2185 nfdset = howmany(n+1, NFDBITS);
2186 /* Explicitly test here, because xrealloc isn't always called */ 2186 /* Explicitly test here, because xrealloc isn't always called */
2187 if (nfdset && SIZE_T_MAX / nfdset < sizeof(fd_mask)) 2187 if (nfdset && SIZE_MAX / nfdset < sizeof(fd_mask))
2188 fatal("channel_prepare_select: max_fd (%d) is too large", n); 2188 fatal("channel_prepare_select: max_fd (%d) is too large", n);
2189 sz = nfdset * sizeof(fd_mask); 2189 sz = nfdset * sizeof(fd_mask);
2190 2190
diff --git a/monitor.c b/monitor.c
index 90db9800b..689586c0f 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor.c,v 1.141 2015/01/20 23:14:00 deraadt Exp $ */ 1/* $OpenBSD: monitor.c,v 1.142 2015/02/06 23:21:59 millert Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -39,9 +39,9 @@
39#endif 39#endif
40#include <pwd.h> 40#include <pwd.h>
41#include <signal.h> 41#include <signal.h>
42#include <stdint.h>
42#include <stdlib.h> 43#include <stdlib.h>
43#include <string.h> 44#include <string.h>
44#include <limits.h>
45#include <stdarg.h> 45#include <stdarg.h>
46#include <stdio.h> 46#include <stdio.h>
47#include <unistd.h> 47#include <unistd.h>
@@ -488,7 +488,7 @@ mm_zalloc(struct mm_master *mm, u_int ncount, u_int size)
488 size_t len = (size_t) size * ncount; 488 size_t len = (size_t) size * ncount;
489 void *address; 489 void *address;
490 490
491 if (len == 0 || ncount > SIZE_T_MAX / size) 491 if (len == 0 || ncount > SIZE_MAX / size)
492 fatal("%s: mm_zalloc(%u, %u)", __func__, ncount, size); 492 fatal("%s: mm_zalloc(%u, %u)", __func__, ncount, size);
493 493
494 address = mm_malloc(mm, len); 494 address = mm_malloc(mm, len);
diff --git a/monitor_mm.c b/monitor_mm.c
index f224fb67e..50731527c 100644
--- a/monitor_mm.c
+++ b/monitor_mm.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor_mm.c,v 1.20 2015/01/20 23:14:00 deraadt Exp $ */ 1/* $OpenBSD: monitor_mm.c,v 1.21 2015/02/06 23:21:59 millert Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * All rights reserved. 4 * All rights reserved.
@@ -35,9 +35,9 @@
35#include <errno.h> 35#include <errno.h>
36#include <stdarg.h> 36#include <stdarg.h>
37#include <stddef.h> 37#include <stddef.h>
38#include <stdint.h>
38#include <stdlib.h> 39#include <stdlib.h>
39#include <string.h> 40#include <string.h>
40#include <limits.h>
41 41
42#include "xmalloc.h" 42#include "xmalloc.h"
43#include "ssh.h" 43#include "ssh.h"
@@ -176,7 +176,7 @@ mm_malloc(struct mm_master *mm, size_t size)
176 176
177 if (size == 0) 177 if (size == 0)
178 fatal("mm_malloc: try to allocate 0 space"); 178 fatal("mm_malloc: try to allocate 0 space");
179 if (size > SIZE_T_MAX - MM_MINSIZE + 1) 179 if (size > SIZE_MAX - MM_MINSIZE + 1)
180 fatal("mm_malloc: size too big"); 180 fatal("mm_malloc: size too big");
181 181
182 size = ((size + (MM_MINSIZE - 1)) / MM_MINSIZE) * MM_MINSIZE; 182 size = ((size + (MM_MINSIZE - 1)) / MM_MINSIZE) * MM_MINSIZE;
diff --git a/xmalloc.c b/xmalloc.c
index 0a9f282ae..fe266cc46 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: xmalloc.c,v 1.30 2015/01/16 06:40:12 deraadt Exp $ */ 1/* $OpenBSD: xmalloc.c,v 1.31 2015/02/06 23:21:59 millert Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -16,10 +16,10 @@
16#include "includes.h" 16#include "includes.h"
17 17
18#include <stdarg.h> 18#include <stdarg.h>
19#include <stdint.h>
19#include <stdio.h> 20#include <stdio.h>
20#include <stdlib.h> 21#include <stdlib.h>
21#include <string.h> 22#include <string.h>
22#include <limits.h>
23 23
24#include "xmalloc.h" 24#include "xmalloc.h"
25#include "log.h" 25#include "log.h"
@@ -44,8 +44,8 @@ xcalloc(size_t nmemb, size_t size)
44 44
45 if (size == 0 || nmemb == 0) 45 if (size == 0 || nmemb == 0)
46 fatal("xcalloc: zero size"); 46 fatal("xcalloc: zero size");
47 if (SIZE_T_MAX / nmemb < size) 47 if (SIZE_MAX / nmemb < size)
48 fatal("xcalloc: nmemb * size > SIZE_T_MAX"); 48 fatal("xcalloc: nmemb * size > SIZE_MAX");
49 ptr = calloc(nmemb, size); 49 ptr = calloc(nmemb, size);
50 if (ptr == NULL) 50 if (ptr == NULL)
51 fatal("xcalloc: out of memory (allocating %zu bytes)", 51 fatal("xcalloc: out of memory (allocating %zu bytes)",
@@ -61,8 +61,8 @@ xrealloc(void *ptr, size_t nmemb, size_t size)
61 61
62 if (new_size == 0) 62 if (new_size == 0)
63 fatal("xrealloc: zero size"); 63 fatal("xrealloc: zero size");
64 if (SIZE_T_MAX / nmemb < size) 64 if (SIZE_MAX / nmemb < size)
65 fatal("xrealloc: nmemb * size > SIZE_T_MAX"); 65 fatal("xrealloc: nmemb * size > SIZE_MAX");
66 if (ptr == NULL) 66 if (ptr == NULL)
67 new_ptr = malloc(new_size); 67 new_ptr = malloc(new_size);
68 else 68 else