Browse Source

Use SIZE_MAX instead of SIZE_T_MAX, the latter is not POSIX and

remove redundant check on size. ok millert@ deraadt@
OPENBSD_4_0
otto 18 years ago
parent
commit
e9112488f5
2 changed files with 4 additions and 4 deletions
  1. +2
    -2
      src/lib/libc/stdlib/calloc.c
  2. +2
    -2
      src/lib/libc/stdlib/malloc.3

+ 2
- 2
src/lib/libc/stdlib/calloc.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: calloc.c,v 1.10 2005/08/08 08:05:36 espie Exp $ */
/* $OpenBSD: calloc.c,v 1.11 2006/04/02 18:22:14 otto Exp $ */
/*- /*-
* Copyright (c) 1990 The Regents of the University of California. * Copyright (c) 1990 The Regents of the University of California.
* All rights reserved. * All rights reserved.
@ -38,7 +38,7 @@ calloc(size_t num, size_t size)
{ {
void *p; void *p;
if (num && size && SIZE_T_MAX / num < size) {
if (num && SIZE_MAX / num < size) {
errno = ENOMEM; errno = ENOMEM;
return NULL; return NULL;
} }


+ 2
- 2
src/lib/libc/stdlib/malloc.3 View File

@ -30,7 +30,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE. .\" SUCH DAMAGE.
.\" .\"
.\" $OpenBSD: malloc.3,v 1.43 2006/03/26 19:56:08 ray Exp $
.\" $OpenBSD: malloc.3,v 1.44 2006/04/02 18:22:14 otto Exp $
.\" .\"
.Dd August 27, 1996 .Dd August 27, 1996
.Dt MALLOC 3 .Dt MALLOC 3
@ -100,7 +100,7 @@ If
.Fn malloc .Fn malloc
must be used, be sure to test for overflow: must be used, be sure to test for overflow:
.Bd -literal -offset indent .Bd -literal -offset indent
if (num && size && SIZE_T_MAX / num < size) {
if (num && SIZE_MAX / num < size) {
errno = ENOMEM; errno = ENOMEM;
err(1, "overflow"); err(1, "overflow");
} }


Loading…
Cancel
Save