From: Andre Date: Wed, 21 Jun 2006 22:20:20 +0000 (+0200) Subject: fix memset bug in enable_crypt() X-Git-Tag: v0.2.14~60^2~6 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=ec58ecae85b1491efb1c25d78d83bc83b9e6a10b 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. --- 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; }