ikev1: Accept IPComp proposals with 4 octet long CPI values

While they SHOULD be sent as 16-bit values according to RFC 3173
a responder MUST be able to accept CPI values encoded in four bytes.
This commit is contained in:
Tobias Brunner
2014-12-05 15:48:52 +01:00
parent 42e0a317c6
commit 4141f01671
@@ -345,7 +345,7 @@ METHOD(payload_t, verify, status_t,
switch (this->protocol_id) switch (this->protocol_id)
{ {
case PROTO_IPCOMP: case PROTO_IPCOMP:
if (this->spi.len != 2) if (this->spi.len != 2 && this->spi.len != 4)
{ {
DBG1(DBG_ENC, "invalid CPI length in IPCOMP proposal"); DBG1(DBG_ENC, "invalid CPI length in IPCOMP proposal");
return FAILED; return FAILED;
@@ -536,7 +536,7 @@ METHOD(proposal_substructure_t, get_cpi, bool,
{ {
if (cpi) if (cpi)
{ {
*cpi = *((u_int16_t*)this->spi.ptr); *cpi = htons(untoh16(this->spi.ptr + this->spi.len - 2));
} }
enumerator->destroy(enumerator); enumerator->destroy(enumerator);
return TRUE; return TRUE;