version 1.10, 2009/01/19 07:21:59 |
version 1.11, 2009/01/19 09:43:11 |
Line 92 static int put_password_attr(struct rad |
|
Line 92 static int put_password_attr(struct rad |
|
const void *, size_t); |
const void *, size_t); |
static int put_raw_attr(struct rad_handle *, int, |
static int put_raw_attr(struct rad_handle *, int, |
const void *, size_t); |
const void *, size_t); |
static int split(char *, const char *[], size_t, char *, size_t); |
static size_t split(char *, const char *[], size_t, char *, size_t); |
|
|
static void |
static void |
clear_password(struct rad_handle *h) |
clear_password(struct rad_handle *h) |
Line 420 rad_config(struct rad_handle *h, const c |
|
Line 420 rad_config(struct rad_handle *h, const c |
|
while (fgets(buf, (int)sizeof buf, fp) != NULL) { |
while (fgets(buf, (int)sizeof buf, fp) != NULL) { |
size_t len; |
size_t len; |
const char *fields[5]; |
const char *fields[5]; |
int nfields; |
size_t nfields; |
char msg[ERRSIZE]; |
char msg[ERRSIZE]; |
const char *type; |
const char *type; |
const char *host; |
const char *host; |
Line 452 rad_config(struct rad_handle *h, const c |
|
Line 452 rad_config(struct rad_handle *h, const c |
|
buf[len - 1] = '\0'; |
buf[len - 1] = '\0'; |
|
|
/* Extract the fields from the line. */ |
/* Extract the fields from the line. */ |
|
msg[0] = '\0'; |
nfields = split(buf, fields, sizeof(fields) / sizeof(fields[0]), |
nfields = split(buf, fields, sizeof(fields) / sizeof(fields[0]), |
msg, sizeof msg); |
msg, sizeof msg); |
if (nfields == -1) { |
if (msg[0] != '\0') { |
generr(h, "%s:%d: %s", path, linenum, msg); |
generr(h, "%s:%d: %s", path, linenum, msg); |
retval = -1; |
retval = -1; |
break; |
break; |
Line 986 rad_strerror(struct rad_handle *h) |
|
Line 987 rad_strerror(struct rad_handle *h) |
|
* The return value is the actual number of fields parsed, and is always |
* The return value is the actual number of fields parsed, and is always |
* <= maxfields. |
* <= maxfields. |
* |
* |
* On a syntax error, places a message in the msg string, and returns -1. |
* On a syntax error, places a message in the msg string, and returns |
|
* SIZE_MAX. |
*/ |
*/ |
static int |
static size_t |
split(char *str, const char *fields[], size_t maxfields, char *msg, |
split(char *str, const char *fields[], size_t maxfields, char *msg, |
size_t msglen) |
size_t msglen) |
{ |
{ |
Line 1006 split(char *str, const char *fields[], s |
|
Line 1008 split(char *str, const char *fields[], s |
|
break; |
break; |
if (i >= maxfields) { |
if (i >= maxfields) { |
snprintf(msg, msglen, "line has too many fields"); |
snprintf(msg, msglen, "line has too many fields"); |
return -1; |
return SIZE_MAX; |
} |
} |
if (*p == '"') { |
if (*p == '"') { |
char *dst; |
char *dst; |
Line 1020 split(char *str, const char *fields[], s |
|
Line 1022 split(char *str, const char *fields[], s |
|
*p != '\0') { |
*p != '\0') { |
snprintf(msg, msglen, |
snprintf(msg, msglen, |
"invalid `\\' escape"); |
"invalid `\\' escape"); |
return -1; |
return SIZE_MAX; |
} |
} |
} |
} |
if (*p == '\0') { |
if (*p == '\0') { |
snprintf(msg, msglen, |
snprintf(msg, msglen, |
"unterminated quoted string"); |
"unterminated quoted string"); |
return -1; |
return SIZE_MAX; |
} |
} |
*dst++ = *p++; |
*dst++ = *p++; |
} |
} |
Line 1035 split(char *str, const char *fields[], s |
|
Line 1037 split(char *str, const char *fields[], s |
|
if (*fields[i] == '\0') { |
if (*fields[i] == '\0') { |
snprintf(msg, msglen, |
snprintf(msg, msglen, |
"empty quoted string not permitted"); |
"empty quoted string not permitted"); |
return -1; |
return SIZE_MAX; |
} |
} |
if (*p != '\0' && strspn(p, ws) == 0) { |
if (*p != '\0' && strspn(p, ws) == 0) { |
snprintf(msg, msglen, "quoted string not" |
snprintf(msg, msglen, "quoted string not" |
" followed by white space"); |
" followed by white space"); |
return -1; |
return SIZE_MAX; |
} |
} |
} else { |
} else { |
fields[i] = p; |
fields[i] = p; |