From 89c22ebc4129f4abaf8dbb416b87ba423c1abe58 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Tue, 15 Jul 2014 23:14:51 -0700 Subject: Use xcalloc instead of xmalloc with calculated sizes Ensure we don't have integer overflow when allocating the array of struct iovec for store commands. Change-Id: I0777ca8ef050b9773dba0c03b5e8533d3b2d5486 Reviewed-on: https://gerrit.stanford.edu/1560 Reviewed-by: Russ Allbery Tested-by: Russ Allbery --- client/wallet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/wallet.c b/client/wallet.c index 09e9664..c3b039f 100644 --- a/client/wallet.c +++ b/client/wallet.c @@ -2,7 +2,7 @@ * The client program for the wallet system. * * Written by Russ Allbery - * Copyright 2006, 2007, 2008, 2010 + * Copyright 2006, 2007, 2008, 2010, 2014 * The Board of Trustees of the Leland Stanford Junior University * * See LICENSE for licensing terms. @@ -181,7 +181,7 @@ main(int argc, char *argv[]) else if (argc < 4) count++; } - command = xmalloc(sizeof(struct iovec) * count); + command = xcalloc(count, sizeof(struct iovec)); command[0].iov_base = (char *) options.type; command[0].iov_len = strlen(options.type); for (i = 0; i < argc; i++) { -- cgit v1.2.3