From 6ebd04219f0d749c87a763e8afb578dfcd5223cc Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Sun, 2 Sep 2007 15:19:41 +0000 Subject: use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg --- usr.bin/grep/grep.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'usr.bin/grep/grep.c') diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index a8a35e3b702..a78b66b1d51 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grep.c,v 1.38 2007/02/13 21:48:20 kili Exp $ */ +/* $OpenBSD: grep.c,v 1.39 2007/09/02 15:19:32 deraadt Exp $ */ /*- * Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav @@ -450,8 +450,8 @@ main(int argc, char *argv[]) if (Eflag) cflags |= REG_EXTENDED; - fg_pattern = grep_malloc(patterns * sizeof(*fg_pattern)); - r_pattern = grep_malloc(patterns * sizeof(*r_pattern)); + fg_pattern = grep_calloc(patterns, sizeof(*fg_pattern)); + r_pattern = grep_calloc(patterns, sizeof(*r_pattern)); for (i = 0; i < patterns; ++i) { /* Check if cheating is allowed (always is for fgrep). */ if (Fflag) { -- cgit v1.2.3