Use variable length arrays instead of alloca().
authorGuus Sliepen <guus@tinc-vpn.org>
Sat, 13 Nov 2010 14:55:38 +0000 (15:55 +0100)
committerGuus Sliepen <guus@tinc-vpn.org>
Sat, 13 Nov 2010 14:55:38 +0000 (15:55 +0100)
src/process.c
src/protocol_auth.c
src/protocol_key.c

index f2fff1d..b305456 100644 (file)
@@ -397,7 +397,7 @@ bool execute_script(const char *name, char **envp) {
        for(i = 0; envp[i]; i++) {
                char *e = strchr(envp[i], '=');
                if(e) {
        for(i = 0; envp[i]; i++) {
                char *e = strchr(envp[i], '=');
                if(e) {
-                       p = alloca(e - envp[i] + 1);
+                       p[e - envp[i] + 1];
                        strncpy(p, envp[i], e - envp[i]);
                        p[e - envp[i]] = '\0';
                        putenv(p);
                        strncpy(p, envp[i], e - envp[i]);
                        p[e - envp[i]] = '\0';
                        putenv(p);
index 3f4fa01..cde7ead 100644 (file)
@@ -109,15 +109,13 @@ bool id_h(connection_t *c) {
 }
 
 bool send_metakey(connection_t *c) {
 }
 
 bool send_metakey(connection_t *c) {
-       char *buffer;
-       int len;
        bool x;
 
        bool x;
 
-       len = RSA_size(c->rsa_key);
+       int len = RSA_size(c->rsa_key);
 
        /* Allocate buffers for the meta key */
 
 
        /* Allocate buffers for the meta key */
 
-       buffer = alloca(2 * len + 1);
+       char buffer[2 * len + 1];
        
        c->outkey = xrealloc(c->outkey, len);
 
        
        c->outkey = xrealloc(c->outkey, len);
 
@@ -287,16 +285,13 @@ bool metakey_h(connection_t *c) {
 }
 
 bool send_challenge(connection_t *c) {
 }
 
 bool send_challenge(connection_t *c) {
-       char *buffer;
-       int len;
-
        /* CHECKME: what is most reasonable value for len? */
 
        /* CHECKME: what is most reasonable value for len? */
 
-       len = RSA_size(c->rsa_key);
+       int len = RSA_size(c->rsa_key);
 
        /* Allocate buffers for the challenge */
 
 
        /* Allocate buffers for the challenge */
 
-       buffer = alloca(2 * len + 1);
+       char buffer[2 * len + 1];
 
        c->hischallenge = xrealloc(c->hischallenge, len);
 
 
        c->hischallenge = xrealloc(c->hischallenge, len);
 
index 22692bb..b326b8d 100644 (file)
@@ -145,8 +145,6 @@ bool req_key_h(connection_t *c) {
 }
 
 bool send_ans_key(node_t *to) {
 }
 
 bool send_ans_key(node_t *to) {
-       char *key;
-
        // Set key parameters
        to->incipher = myself->incipher;
        to->inkeylength = myself->inkeylength;
        // Set key parameters
        to->incipher = myself->incipher;
        to->inkeylength = myself->inkeylength;
@@ -168,7 +166,7 @@ bool send_ans_key(node_t *to) {
        memset(to->late, 0, sizeof(to->late));
 
        // Convert to hexadecimal and send
        memset(to->late, 0, sizeof(to->late));
 
        // Convert to hexadecimal and send
-       key = alloca(2 * to->inkeylength + 1);
+       char key[2 * to->inkeylength + 1];
        bin2hex(to->inkey, key, to->inkeylength);
        key[to->inkeylength * 2] = '\0';
 
        bin2hex(to->inkey, key, to->inkeylength);
        key[to->inkeylength * 2] = '\0';