diff options
author | Martin Willi <martin@revosec.ch> | 2010-02-05 11:30:01 +0000 |
---|---|---|
committer | Martin Willi <martin@revosec.ch> | 2010-08-03 15:39:25 +0200 |
commit | 3e7e7779414f17ebf735e12e19c99ca1e8235ac7 (patch) | |
tree | a4a5b2c7a0efc442cb343c7f3d6d9dbff2ae2052 | |
parent | 51313a39d107be83686eeeae32faef8c8343a99d (diff) | |
download | strongswan-3e7e7779414f17ebf735e12e19c99ca1e8235ac7.tar.bz2 strongswan-3e7e7779414f17ebf735e12e19c99ca1e8235ac7.tar.xz |
Properly send empty EAP-TLS messages
-rw-r--r-- | src/charon/plugins/eap_tls/eap_tls.c | 47 |
1 files changed, 25 insertions, 22 deletions
diff --git a/src/charon/plugins/eap_tls/eap_tls.c b/src/charon/plugins/eap_tls/eap_tls.c index 4e543d45d..25cb7775c 100644 --- a/src/charon/plugins/eap_tls/eap_tls.c +++ b/src/charon/plugins/eap_tls/eap_tls.c @@ -215,29 +215,32 @@ static eap_payload_t *read_buf(private_eap_tls_t *this, u_int8_t identifier) pkt->type = EAP_TLS; pkt->flags = 0; - start = (char*)(pkt + 1); - if (this->outpos == 0) - { /* first fragment */ - pkt->flags = EAP_TLS_LENGTH; - pkt_len += 4; - start += 4; - htoun32(pkt + 1, this->output.len); - } - - if (this->output.len - this->outpos > EAP_TLS_FRAGMENT_LEN) - { - pkt->flags |= EAP_TLS_MORE_FRAGS; - pkt_len += EAP_TLS_FRAGMENT_LEN; - memcpy(start, this->output.ptr + this->outpos, EAP_TLS_FRAGMENT_LEN); - this->outpos += EAP_TLS_FRAGMENT_LEN; - } - else + if (this->output.len) { - pkt_len += this->output.len - this->outpos; - memcpy(start, this->output.ptr + this->outpos, - this->output.len - this->outpos); - chunk_free(&this->output); - this->outpos = 0; + start = (char*)(pkt + 1); + if (this->outpos == 0) + { /* first fragment */ + pkt->flags = EAP_TLS_LENGTH; + pkt_len += 4; + start += 4; + htoun32(pkt + 1, this->output.len); + } + + if (this->output.len - this->outpos > EAP_TLS_FRAGMENT_LEN) + { + pkt->flags |= EAP_TLS_MORE_FRAGS; + pkt_len += EAP_TLS_FRAGMENT_LEN; + memcpy(start, this->output.ptr + this->outpos, EAP_TLS_FRAGMENT_LEN); + this->outpos += EAP_TLS_FRAGMENT_LEN; + } + else + { + pkt_len += this->output.len - this->outpos; + memcpy(start, this->output.ptr + this->outpos, + this->output.len - this->outpos); + chunk_free(&this->output); + this->outpos = 0; + } } htoun16(&pkt->length, pkt_len); return eap_payload_create_data(chunk_create(buf, pkt_len)); |