aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Willi <martin@strongswan.org>2009-11-23 13:49:19 +0100
committerMartin Willi <martin@strongswan.org>2009-11-23 13:49:19 +0100
commit0d1d19b99d5cad06685fd62ba9021e510f6cd03e (patch)
treeff55a8108a1ef7365d18bdd178454ec2bbb20435
parentad78bb13c84bacae3b1b5ee388ea784d5bfe7f53 (diff)
downloadstrongswan-0d1d19b99d5cad06685fd62ba9021e510f6cd03e.tar.bz2
strongswan-0d1d19b99d5cad06685fd62ba9021e510f6cd03e.tar.xz
Avoid potentially unaligned half-word read
-rw-r--r--src/charon/sa/tasks/child_create.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/charon/sa/tasks/child_create.c b/src/charon/sa/tasks/child_create.c
index def190d23..6325b878c 100644
--- a/src/charon/sa/tasks/child_create.c
+++ b/src/charon/sa/tasks/child_create.c
@@ -1011,15 +1011,18 @@ static status_t process_i(private_child_create_t *this, message_t *message)
case INVALID_KE_PAYLOAD:
{
chunk_t data;
- diffie_hellman_group_t bad_group;
+ u_int16_t group = MODP_NONE;
- bad_group = this->dh_group;
data = notify->get_notification_data(notify);
- this->dh_group = ntohs(*((u_int16_t*)data.ptr));
+ if (data.len == sizeof(group))
+ {
+ memcpy(&group, data.ptr, data.len);
+ group = ntohs(group);
+ }
DBG1(DBG_IKE, "peer didn't accept DH group %N, "
"it requested %N", diffie_hellman_group_names,
- bad_group, diffie_hellman_group_names, this->dh_group);
-
+ this->dh_group, diffie_hellman_group_names, group);
+ this->dh_group = group;
this->public.task.migrate(&this->public.task, this->ike_sa);
enumerator->destroy(enumerator);
return NEED_MORE;