fixed some newline encodings
This commit is contained in:
@@ -45,16 +45,16 @@ struct private_eap_sim_file_triplets_t {
|
||||
* mutex to lock triplets list
|
||||
*/
|
||||
mutex_t *mutex;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* A single triplet
|
||||
*/
|
||||
typedef struct {
|
||||
identification_t *imsi;
|
||||
char rand[RAND_LEN];
|
||||
char sres[SRES_LEN];
|
||||
char kc[KC_LEN];
|
||||
*/
|
||||
typedef struct {
|
||||
identification_t *imsi;
|
||||
char rand[RAND_LEN];
|
||||
char sres[SRES_LEN];
|
||||
char kc[KC_LEN];
|
||||
} triplet_t;
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ static bool enumerator_enumerate(triplet_enumerator_t *e, identification_t **ims
|
||||
char **rand, char **sres, char **kc)
|
||||
{
|
||||
triplet_t *triplet;
|
||||
|
||||
|
||||
if (e->inner->enumerate(e->inner, &triplet))
|
||||
{
|
||||
e->current = triplet;
|
||||
@@ -148,45 +148,45 @@ static void parse_token(char *to, char *from, size_t len)
|
||||
memset(to, 0, len);
|
||||
memcpy(to + len - chunk.len, chunk.ptr, chunk.len);
|
||||
free(chunk.ptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the triplets from the file
|
||||
*/
|
||||
static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
|
||||
{
|
||||
char line[512];
|
||||
FILE *file;
|
||||
int i, nr = 0;
|
||||
|
||||
file = fopen(path, "r");
|
||||
if (file == NULL)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the triplets from the file
|
||||
*/
|
||||
static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
|
||||
{
|
||||
char line[512];
|
||||
FILE *file;
|
||||
int i, nr = 0;
|
||||
|
||||
file = fopen(path, "r");
|
||||
if (file == NULL)
|
||||
{
|
||||
DBG1(DBG_CFG, "opening triplet file %s failed: %s",
|
||||
path, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
/* read line by line */
|
||||
while (fgets(line, sizeof(line), file))
|
||||
{
|
||||
path, strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
/* read line by line */
|
||||
while (fgets(line, sizeof(line), file))
|
||||
{
|
||||
triplet_t *triplet;
|
||||
enumerator_t *enumerator;
|
||||
char *token;
|
||||
|
||||
nr++;
|
||||
/* skip comments, empty lines */
|
||||
switch (line[0])
|
||||
{
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '#':
|
||||
case '\0':
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
|
||||
nr++;
|
||||
/* skip comments, empty lines */
|
||||
switch (line[0])
|
||||
{
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '#':
|
||||
case '\0':
|
||||
continue;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
triplet = malloc_thing(triplet_t);
|
||||
triplet = malloc_thing(triplet_t);
|
||||
memset(triplet, 0, sizeof(triplet_t));
|
||||
|
||||
i = 0;
|
||||
@@ -214,22 +214,22 @@ static void read_triplets(private_eap_sim_file_triplets_t *this, char *path)
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
if (i < 4)
|
||||
{
|
||||
{
|
||||
DBG1(DBG_CFG, "error in triplet file, line %d", nr);
|
||||
triplet_destroy(triplet);
|
||||
continue;
|
||||
}
|
||||
|
||||
DBG2(DBG_CFG, "triplet: imsi %D\nrand %b\nsres %b\nkc %b",
|
||||
triplet->imsi, triplet->rand, RAND_LEN,
|
||||
}
|
||||
|
||||
DBG2(DBG_CFG, "triplet: imsi %D\nrand %b\nsres %b\nkc %b",
|
||||
triplet->imsi, triplet->rand, RAND_LEN,
|
||||
triplet->sres, SRES_LEN, triplet->kc, KC_LEN);
|
||||
|
||||
this->triplets->insert_last(this->triplets, triplet);
|
||||
}
|
||||
this->triplets->insert_last(this->triplets, triplet);
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
|
||||
DBG1(DBG_CFG, "read %d triplets from %s",
|
||||
this->triplets->get_count(this->triplets), path);
|
||||
this->triplets->get_count(this->triplets), path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,17 +28,17 @@
|
||||
|
||||
/**
|
||||
* size of RAND value
|
||||
*/
|
||||
*/
|
||||
#define RAND_LEN 16
|
||||
|
||||
/**
|
||||
* size of SRES value
|
||||
*/
|
||||
*/
|
||||
#define SRES_LEN 4
|
||||
|
||||
/**
|
||||
* size of KC value
|
||||
*/
|
||||
*/
|
||||
#define KC_LEN 8
|
||||
|
||||
typedef struct eap_sim_file_triplets_t eap_sim_file_triplets_t;
|
||||
@@ -46,7 +46,7 @@ typedef struct eap_sim_file_triplets_t eap_sim_file_triplets_t;
|
||||
/**
|
||||
* Reads triplets from a triplets.dat file.
|
||||
*
|
||||
* The file is in freeradius triplet file syntax:
|
||||
* The file is in freeradius triplet file syntax:
|
||||
* http://www.freeradius.org/radiusd/doc/rlm_sim_triplets
|
||||
*/
|
||||
struct eap_sim_file_triplets_t {
|
||||
|
||||
Reference in New Issue
Block a user