From ec58ecae85b1491efb1c25d78d83bc83b9e6a10b Mon Sep 17 00:00:00 2001 From: Andre Date: Thu, 22 Jun 2006 00:20:20 +0200 Subject: [PATCH] fix memset bug in enable_crypt() A high-quality stealth bug. It bites only if enough fds are open, and the trouble shows up much later. Kill the sucker with pleasure. --- net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net.c b/net.c index 5a7eb917..c70c658c 100644 --- a/net.c +++ b/net.c @@ -30,8 +30,8 @@ struct crypt_data { crypt_function *send; void *private_data; }; -static struct crypt_data *crypt_data_array; static unsigned cda_size = 0; +static struct crypt_data *crypt_data_array; /** \endcond */ @@ -49,7 +49,7 @@ void enable_crypt(int fd, crypt_function *recv, crypt_function *send, if (fd + 1 > cda_size) { crypt_data_array = para_realloc(crypt_data_array, (fd + 1) * sizeof(struct crypt_data)); - memset(crypt_data_array + cda_size * sizeof(struct crypt_data), 0, + memset(crypt_data_array + cda_size, 0, (fd + 1 - cda_size) * sizeof(struct crypt_data)); cda_size = fd + 1; } -- 2.39.2