=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rcs/xmalloc.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/rcs/xmalloc.c 2007/02/27 07:59:13 1.3 --- src/usr.bin/rcs/xmalloc.c 2009/06/07 08:39:13 1.4 *************** *** 1,4 **** ! /* $OpenBSD: xmalloc.c,v 1.3 2007/02/27 07:59:13 xsa Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland --- 1,4 ---- ! /* $OpenBSD: xmalloc.c,v 1.4 2009/06/07 08:39:13 ray Exp $ */ /* * Author: Tatu Ylonen * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland *************** *** 44,51 **** if (size == 0 || nmemb == 0) errx(1, "xcalloc: zero size"); ! if (SIZE_T_MAX / nmemb < size) ! errx(1, "xcalloc: nmemb * size > SIZE_T_MAX"); ptr = calloc(nmemb, size); if (ptr == NULL) errx(1, "xcalloc: out of memory (allocating %lu bytes)", --- 44,51 ---- if (size == 0 || nmemb == 0) errx(1, "xcalloc: zero size"); ! if (SIZE_MAX / nmemb < size) ! errx(1, "xcalloc: nmemb * size > SIZE_MAX"); ptr = calloc(nmemb, size); if (ptr == NULL) errx(1, "xcalloc: out of memory (allocating %lu bytes)", *************** *** 61,68 **** if (new_size == 0) errx(1, "xrealloc: zero size"); ! if (SIZE_T_MAX / nmemb < size) ! errx(1, "xrealloc: nmemb * size > SIZE_T_MAX"); if (ptr == NULL) new_ptr = malloc(new_size); else --- 61,68 ---- if (new_size == 0) errx(1, "xrealloc: zero size"); ! if (SIZE_MAX / nmemb < size) ! errx(1, "xrealloc: nmemb * size > SIZE_MAX"); if (ptr == NULL) new_ptr = malloc(new_size); else