~ubuntu-branches/ubuntu/utopic/freeradius/utopic

« back to all changes in this revision

Viewing changes to src/modules/rlm_eap/libeap/eapsimlib.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2006-12-16 20:45:11 UTC
  • mfrom: (3.1.10 feisty)
  • Revision ID: james.westby@ubuntu.com-20061216204511-3pbbsu4s8jtehsor
Tags: 1.1.3-3
Fix POSIX compliance problem in init script.  Closes: #403384. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 *
7
7
 * code common to EAP-SIM clients and to servers.
8
8
 *
9
 
 * Version:     $Id: eapsimlib.c,v 1.7 2004/04/06 01:00:36 mcr Exp $
 
9
 * Version:     $Id: eapsimlib.c,v 1.7.2.2 2005/01/26 20:31:31 aland Exp $
10
10
 *
11
11
 *   This program is free software; you can redistribute it and/or modify
12
12
 *   it under the terms of the GNU General Public License as published by
53
53
#include "eap_sim.h"
54
54
#include "sha1.h"
55
55
 
56
 
static const char rcsid[] = "$Id: eapsimlib.c,v 1.7 2004/04/06 01:00:36 mcr Exp $";
 
56
static const char rcsid[] = "$Id: eapsimlib.c,v 1.7.2.2 2005/01/26 20:31:31 aland Exp $";
57
57
 
58
58
/*
59
59
 * given a radius request with many attribues in the EAP-SIM range, build
146
146
                encoded_size += roundedlen;
147
147
        }
148
148
 
 
149
        if (ep->code != PW_EAP_SUCCESS)
 
150
                ep->code = eapcode;
 
151
        ep->id = (id & 0xff);
 
152
        ep->type.type = PW_EAP_SIM;
 
153
 
149
154
        /*
150
155
         * if no attributes were found, do very little.
151
156
         *
153
158
        if(encoded_size == 0)
154
159
        {
155
160
                encodedmsg = malloc(3);
 
161
                /* FIX: could be NULL */
156
162
 
157
163
                encodedmsg[0]=subtype;
158
164
                encodedmsg[1]=0;
159
165
                encodedmsg[2]=0;
160
166
 
161
 
                ep->code = eapcode;
162
 
                ep->id   = (id & 0xff);
163
 
                ep->type.type = PW_EAP_SIM;
164
167
                ep->type.length = 3;
165
168
                ep->type.data = encodedmsg;
166
169
 
365
368
                        return 0;
366
369
                }
367
370
 
368
 
                newvp = paircreate(eapsim_attribute+ATTRIBUTE_EAP_SIM_BASE, PW_TYPE_OCTETS);
369
371
                if(eapsim_len > MAX_STRING_LEN) {
370
372
                        eapsim_len = MAX_STRING_LEN;
371
373
                }
 
374
                if (eapsim_len < 2) {
 
375
                        radlog(L_ERR, "eap: EAP-Sim attribute %d (no.%d) has length too small",
 
376
                               eapsim_attribute, es_attribute_count);
 
377
                               return 0;
 
378
                }
 
379
 
 
380
                newvp = paircreate(eapsim_attribute+ATTRIBUTE_EAP_SIM_BASE, PW_TYPE_OCTETS);
372
381
                memcpy(newvp->strvalue, &attr[2], eapsim_len-2);
373
382
                newvp->length = eapsim_len-2;
374
383
                pairadd(&(r->vps), newvp);