summaryrefslogtreecommitdiffstats
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2007-09-02 15:19:07 +0000
committerderaadt <deraadt@openbsd.org>2007-09-02 15:19:07 +0000
commit1ed98fdf61d9dd29369f246109081408082ce54d (patch)
treead7631e58c83830d1fc51cbadb9a2da53c1abfb7 /usr.bin/patch
parentOpenCVS server init-support with OpenCVS and GNU cvs clients. (diff)
downloadwireguard-openbsd-1ed98fdf61d9dd29369f246109081408082ce54d.tar.xz
wireguard-openbsd-1ed98fdf61d9dd29369f246109081408082ce54d.zip
use calloc() to avoid malloc(n * m) overflows; checked by djm canacar jsg
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/pch.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
index e41ddf8c757..c2d1eeab021 100644
--- a/usr.bin/patch/pch.c
+++ b/usr.bin/patch/pch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pch.c,v 1.36 2006/03/11 19:41:30 otto Exp $ */
+/* $OpenBSD: pch.c,v 1.37 2007/09/02 15:19:33 deraadt Exp $ */
/*
* patch - a program to apply diffs to original files
@@ -27,7 +27,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: pch.c,v 1.36 2006/03/11 19:41:30 otto Exp $";
+static const char rcsid[] = "$OpenBSD: pch.c,v 1.37 2007/09/02 15:19:33 deraadt Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -129,11 +129,11 @@ void
set_hunkmax(void)
{
if (p_line == NULL)
- p_line = malloc((size_t) hunkmax * sizeof(char *));
+ p_line = calloc((size_t) hunkmax, sizeof(char *));
if (p_len == NULL)
- p_len = malloc((size_t) hunkmax * sizeof(short));
+ p_len = calloc((size_t) hunkmax, sizeof(short));
if (p_char == NULL)
- p_char = malloc((size_t) hunkmax * sizeof(char));
+ p_char = calloc((size_t) hunkmax, sizeof(char));
}
/*