aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2008-08-21 07:55:16 +0000
committerMartin Willi <martin@strongswan.org>2008-08-21 07:55:16 +0000
commit02e907fe664a574fcf827cb2a95ee00d528daf1e (patch)
tree93379d6a3673ac96f09c4c9b6042285cbc75c174 /src
parentbdbf3c49fcce4ac4e6634ae26a6af1e77b3793c8 (diff)
downloadstrongswan-02e907fe664a574fcf827cb2a95ee00d528daf1e.tar.bz2
strongswan-02e907fe664a574fcf827cb2a95ee00d528daf1e.tar.xz
avoid too many alloca()s in netlink send, problematic on MIPS
Diffstat (limited to 'src')
-rw-r--r--src/charon/kernel/kernel_interface.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/charon/kernel/kernel_interface.c b/src/charon/kernel/kernel_interface.c
index 0b9d44806..7349eeec7 100644
--- a/src/charon/kernel/kernel_interface.c
+++ b/src/charon/kernel/kernel_interface.c
@@ -1104,12 +1104,14 @@ static status_t netlink_send(private_kernel_interface_t *this,
}
DBG1(DBG_KNL, "error reading from netlink socket: %s", strerror(errno));
pthread_mutex_unlock(&this->nl_mutex);
+ free(result.ptr);
return FAILED;
}
if (!NLMSG_OK(msg, len))
{
DBG1(DBG_KNL, "received corrupted netlink message");
pthread_mutex_unlock(&this->nl_mutex);
+ free(result.ptr);
return FAILED;
}
if (msg->nlmsg_seq != this->seq)
@@ -1120,11 +1122,14 @@ static status_t netlink_send(private_kernel_interface_t *this,
continue;
}
pthread_mutex_unlock(&this->nl_mutex);
+ free(result.ptr);
return FAILED;
}
tmp.len = len;
- result = chunk_cata("cc", result, tmp);
+ result.ptr = realloc(result.ptr, result.len + tmp.len);
+ memcpy(result.ptr + result.len, tmp.ptr, tmp.len);
+ result.len += tmp.len;
/* NLM_F_MULTI flag does not seem to be set correctly, we use sequence
* numbers to detect multi header messages */
@@ -1140,7 +1145,7 @@ static status_t netlink_send(private_kernel_interface_t *this,
}
*out_len = result.len;
- *out = (struct nlmsghdr*)clalloc(result.ptr, result.len);
+ *out = (struct nlmsghdr*)result.ptr;
pthread_mutex_unlock(&this->nl_mutex);