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 --- libexec/spamd-setup/spamd-setup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libexec/spamd-setup') diff --git a/libexec/spamd-setup/spamd-setup.c b/libexec/spamd-setup/spamd-setup.c index 4efcbc5f223..51041a50816 100644 --- a/libexec/spamd-setup/spamd-setup.c +++ b/libexec/spamd-setup/spamd-setup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spamd-setup.c,v 1.32 2007/02/27 02:10:58 beck Exp $ */ +/* $OpenBSD: spamd-setup.c,v 1.33 2007/09/02 15:19:20 deraadt Exp $ */ /* * Copyright (c) 2003 Bob Beck. All rights reserved. @@ -311,7 +311,7 @@ open_file(char *method, char *file) return (i); } else if (strcmp(method, "exec") == 0) { len = strlen(file); - argv = malloc(len * sizeof(char *)); + argv = calloc(len, sizeof(char *)); if (argv == NULL) errx(1, "malloc failed"); for (ap = argv; ap < &argv[len - 1] && @@ -540,7 +540,7 @@ collapse_blacklist(struct bl *bl, size_t blc) if (blc == 0) return (NULL); - cl = malloc(((blc / 2) + 1) * sizeof(struct cidr)); + cl = calloc(((blc / 2) + 1), sizeof(struct cidr)); if (cl == NULL) { return (NULL); } -- cgit v1.2.3