X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fplugins%2Fradius%2Fradrealms.c;h=cd006fd0894cae2cae87ec303daf1256839cbe87;hb=c58bf2e8023dd846683f09cb00e15d64143dac8c;hp=169004248ba6f2b19b615bdd431d96d5bb8dfc96;hpb=fb962146b47be40bd54f1be887ca4b8f4325a273;p=ppp.git diff --git a/pppd/plugins/radius/radrealms.c b/pppd/plugins/radius/radrealms.c index 1690042..cd006fd 100644 --- a/pppd/plugins/radius/radrealms.c +++ b/pppd/plugins/radius/radrealms.c @@ -15,19 +15,21 @@ */ static char const RCSID[] = - "$Id: radrealms.c,v 1.1 2002/10/05 04:35:24 fcusack Exp $"; + "$Id: radrealms.c,v 1.2 2004/11/14 07:26:26 paulus Exp $"; #include "pppd.h" #include "radiusclient.h" #include #include +#include char pppd_version[] = VERSION; char radrealms_config[MAXPATHLEN] = "/etc/radiusclient/realms"; static option_t Options[] = { - { "realms-config-file", o_string, &radrealms_config }, + { "realms-config-file", o_string, &radrealms_config, + "Configuration file for RADIUS realms", OPT_STATIC, NULL, MAXPATHLEN }, { NULL } }; @@ -44,7 +46,7 @@ lookup_realm(char const *user, FILE *fd; SERVER *accts, *auths, *s; char buffer[512], *p; - int line, pos; + int line = 0; auths = (SERVER *) malloc(sizeof(SERVER)); auths->max = 0; @@ -66,10 +68,12 @@ lookup_realm(char const *user, if ((fd = fopen(radrealms_config, "r")) == NULL) { option_error("cannot open %s", radrealms_config); + free(auths); + free(accts); return; - } + } info("Reading %s", radrealms_config); - + while ((fgets(buffer, sizeof(buffer), fd) != NULL)) { line++; @@ -85,6 +89,8 @@ lookup_realm(char const *user, fclose(fd); option_error("%s: invalid line %d: %s", radrealms_config, line, buffer); + free(auths); + free(accts); return; } info("Parsing '%s' entry:", p); @@ -99,6 +105,8 @@ lookup_realm(char const *user, fclose(fd); option_error("%s: realm name missing on line %d: %s", radrealms_config, line, buffer); + free(auths); + free(accts); return; } @@ -109,6 +117,8 @@ lookup_realm(char const *user, fclose(fd); option_error("%s: server address missing on line %d: %s", radrealms_config, line, buffer); + free(auths); + free(accts); return; } s->name[s->max] = strdup(p); @@ -117,6 +127,8 @@ lookup_realm(char const *user, fclose(fd); option_error("%s: server port missing on line %d: %s", radrealms_config, line, buffer); + free(auths); + free(accts); return; } s->port[s->max] = atoi(p);