- OpenBSD CVS Sync
- deraadt@cvs.openbsd.org 2006/03/27 01:21:18 [xmalloc.c] we can do the size & nmemb check before the integer overflow check; evol
This commit is contained in:
parent
b3cdc220c4
commit
da380becc6
|
@ -1,3 +1,10 @@
|
||||||
|
20060331
|
||||||
|
- OpenBSD CVS Sync
|
||||||
|
- deraadt@cvs.openbsd.org 2006/03/27 01:21:18
|
||||||
|
[xmalloc.c]
|
||||||
|
we can do the size & nmemb check before the integer overflow check;
|
||||||
|
evol
|
||||||
|
|
||||||
20060326
|
20060326
|
||||||
- OpenBSD CVS Sync
|
- OpenBSD CVS Sync
|
||||||
- jakob@cvs.openbsd.org 2006/03/15 08:46:44
|
- jakob@cvs.openbsd.org 2006/03/15 08:46:44
|
||||||
|
@ -4446,4 +4453,4 @@
|
||||||
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
- (djm) Trim deprecated options from INSTALL. Mention UsePAM
|
||||||
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
- (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
|
||||||
|
|
||||||
$Id: ChangeLog,v 1.4287 2006/03/26 03:30:33 djm Exp $
|
$Id: ChangeLog,v 1.4288 2006/03/31 12:09:17 djm Exp $
|
||||||
|
|
10
xmalloc.c
10
xmalloc.c
|
@ -1,4 +1,4 @@
|
||||||
/* $OpenBSD: xmalloc.c,v 1.20 2006/03/25 13:17:03 djm Exp $ */
|
/* $OpenBSD: xmalloc.c,v 1.21 2006/03/27 01:21:18 deraadt Exp $ */
|
||||||
/*
|
/*
|
||||||
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
* Author: Tatu Ylonen <ylo@cs.hut.fi>
|
||||||
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
|
||||||
|
@ -36,10 +36,10 @@ xcalloc(size_t nmemb, size_t size)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
if (nmemb && size && SIZE_T_MAX / nmemb < size)
|
|
||||||
fatal("xcalloc: nmemb * size > SIZE_T_MAX");
|
|
||||||
if (size == 0 || nmemb == 0)
|
if (size == 0 || nmemb == 0)
|
||||||
fatal("xcalloc: zero size");
|
fatal("xcalloc: zero size");
|
||||||
|
if (SIZE_T_MAX / nmemb < size)
|
||||||
|
fatal("xcalloc: nmemb * size > SIZE_T_MAX");
|
||||||
ptr = calloc(nmemb, size);
|
ptr = calloc(nmemb, size);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
fatal("xcalloc: out of memory (allocating %lu bytes)",
|
fatal("xcalloc: out of memory (allocating %lu bytes)",
|
||||||
|
@ -53,10 +53,10 @@ xrealloc(void *ptr, size_t nmemb, size_t size)
|
||||||
void *new_ptr;
|
void *new_ptr;
|
||||||
size_t new_size = nmemb * size;
|
size_t new_size = nmemb * size;
|
||||||
|
|
||||||
if (nmemb && size && SIZE_T_MAX / nmemb < size)
|
|
||||||
fatal("xrealloc: nmemb * size > SIZE_T_MAX");
|
|
||||||
if (new_size == 0)
|
if (new_size == 0)
|
||||||
fatal("xrealloc: zero size");
|
fatal("xrealloc: zero size");
|
||||||
|
if (SIZE_T_MAX / nmemb < size)
|
||||||
|
fatal("xrealloc: nmemb * size > SIZE_T_MAX");
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
new_ptr = malloc(new_size);
|
new_ptr = malloc(new_size);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue