Use variable length arrays instead of alloca().
This commit is contained in:
parent
e2e6ec8050
commit
9e3ca39773
3 changed files with 6 additions and 13 deletions
|
@ -397,7 +397,7 @@ bool execute_script(const char *name, char **envp) {
|
||||||
for(i = 0; envp[i]; i++) {
|
for(i = 0; envp[i]; i++) {
|
||||||
char *e = strchr(envp[i], '=');
|
char *e = strchr(envp[i], '=');
|
||||||
if(e) {
|
if(e) {
|
||||||
p = alloca(e - envp[i] + 1);
|
p[e - envp[i] + 1];
|
||||||
strncpy(p, envp[i], e - envp[i]);
|
strncpy(p, envp[i], e - envp[i]);
|
||||||
p[e - envp[i]] = '\0';
|
p[e - envp[i]] = '\0';
|
||||||
putenv(p);
|
putenv(p);
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
@ -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
|
// Set key parameters
|
||||||
to->incipher = myself->incipher;
|
to->incipher = myself->incipher;
|
||||||
to->inkeylength = myself->inkeylength;
|
to->inkeylength = myself->inkeylength;
|
||||||
|
@ -168,7 +166,7 @@ bool send_ans_key(node_t *to) {
|
||||||
memset(to->late, 0, sizeof(to->late));
|
memset(to->late, 0, sizeof(to->late));
|
||||||
|
|
||||||
// Convert to hexadecimal and send
|
// Convert to hexadecimal and send
|
||||||
key = alloca(2 * to->inkeylength + 1);
|
char key[2 * to->inkeylength + 1];
|
||||||
bin2hex(to->inkey, key, to->inkeylength);
|
bin2hex(to->inkey, key, to->inkeylength);
|
||||||
key[to->inkeylength * 2] = '\0';
|
key[to->inkeylength * 2] = '\0';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue