summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--xmalloc.c10
2 files changed, 13 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 93c321c95..7bbc6ce82 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
120060331
2 - OpenBSD CVS Sync
3 - deraadt@cvs.openbsd.org 2006/03/27 01:21:18
4 [xmalloc.c]
5 we can do the size & nmemb check before the integer overflow check;
6 evol
7
120060326 820060326
2 - OpenBSD CVS Sync 9 - OpenBSD CVS Sync
3 - jakob@cvs.openbsd.org 2006/03/15 08:46:44 10 - jakob@cvs.openbsd.org 2006/03/15 08:46:44
@@ -4446,4 +4453,4 @@
4446 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 4453 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
4447 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 4454 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
4448 4455
4449$Id: ChangeLog,v 1.4287 2006/03/26 03:30:33 djm Exp $ 4456$Id: ChangeLog,v 1.4288 2006/03/31 12:09:17 djm Exp $
diff --git a/xmalloc.c b/xmalloc.c
index 9bfa9e6f8..110d8cb7f 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: xmalloc.c,v 1.20 2006/03/25 13:17:03 djm Exp $ */ 1/* $OpenBSD: xmalloc.c,v 1.21 2006/03/27 01:21:18 deraadt 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
@@ -36,10 +36,10 @@ xcalloc(size_t nmemb, size_t size)
36{ 36{
37 void *ptr; 37 void *ptr;
38 38
39 if (nmemb && size && SIZE_T_MAX / nmemb < size)
40 fatal("xcalloc: nmemb * size > SIZE_T_MAX");
41 if (size == 0 || nmemb == 0) 39 if (size == 0 || nmemb == 0)
42 fatal("xcalloc: zero size"); 40 fatal("xcalloc: zero size");
41 if (SIZE_T_MAX / nmemb < size)
42 fatal("xcalloc: nmemb * size > SIZE_T_MAX");
43 ptr = calloc(nmemb, size); 43 ptr = calloc(nmemb, size);
44 if (ptr == NULL) 44 if (ptr == NULL)
45 fatal("xcalloc: out of memory (allocating %lu bytes)", 45 fatal("xcalloc: out of memory (allocating %lu bytes)",
@@ -53,10 +53,10 @@ xrealloc(void *ptr, size_t nmemb, size_t size)
53 void *new_ptr; 53 void *new_ptr;
54 size_t new_size = nmemb * size; 54 size_t new_size = nmemb * size;
55 55
56 if (nmemb && size && SIZE_T_MAX / nmemb < size)
57 fatal("xrealloc: nmemb * size > SIZE_T_MAX");
58 if (new_size == 0) 56 if (new_size == 0)
59 fatal("xrealloc: zero size"); 57 fatal("xrealloc: zero size");
58 if (SIZE_T_MAX / nmemb < size)
59 fatal("xrealloc: nmemb * size > SIZE_T_MAX");
60 if (ptr == NULL) 60 if (ptr == NULL)
61 new_ptr = malloc(new_size); 61 new_ptr = malloc(new_size);
62 else 62 else