]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
fix memset bug in enable_crypt()
authorAndre <maan@p133.(none)>
Wed, 21 Jun 2006 22:20:20 +0000 (00:20 +0200)
committerAndre <maan@p133.(none)>
Wed, 21 Jun 2006 22:20:20 +0000 (00:20 +0200)
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

diff --git a/net.c b/net.c
index 5a7eb9175427c2fcee0f4d3a2532870fb11dcc08..c70c658cda6eb6c4aa92ffd305d99bd72f32c92c 100644 (file)
--- 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;
        }