charon-systemd: Don't use atexit() to deinitialize the daemon
[strongswan.git] / testing / scripts / recipes / patches / freeradius-eap-sim-identity
1 --- a/src/modules/rlm_eap/types/rlm_eap_sim/rlm_eap_sim.c       2012-11-28 11:03:05.081225276 +0100
2 +++ b/src/modules/rlm_eap/types/rlm_eap_sim/rlm_eap_sim.c       2012-11-28 11:46:59.746289881 +0100
3 @@ -246,14 +246,21 @@
4         newvp->vp_integer = ess->sim_id++;
5         pairreplace(outvps, newvp);
6
7 +       ess->keys.identitylen = strlen(handler->identity);
8 +       memcpy(ess->keys.identity, handler->identity, ess->keys.identitylen);
9 +
10         /* make a copy of the identity */
11         newvp = pairfind(*invps, ATTRIBUTE_EAP_SIM_BASE + PW_EAP_SIM_IDENTITY);
12 -       if (newvp) {
13 -               ess->keys.identitylen = newvp->length;
14 -               memcpy(ess->keys.identity, newvp->vp_octets, newvp->length);
15 -       } else {
16 -               ess->keys.identitylen = strlen(handler->identity);
17 -               memcpy(ess->keys.identity, handler->identity, ess->keys.identitylen);
18 +       if (newvp && newvp->length > 2) {
19 +               uint16_t len;
20 +
21 +               memcpy(&len, newvp->vp_octets, sizeof(uint16_t));
22 +               len = ntohs(len);
23 +               if (len <= newvp->length - 2 && len <= MAX_STRING_LEN) {
24 +                       ess->keys.identitylen = len;
25 +                       memcpy(ess->keys.identity, newvp->vp_octets + 2,
26 +                              ess->keys.identitylen);
27 +               }
28         }
29
30         /* all set, calculate keys! */