summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBmo <35866749+XWwalker@users.noreply.github.com>2023-03-18 06:20:43 +0800
committerGitHub <noreply@github.com>2023-03-18 09:20:43 +1100
commit883a65eee0ea9de6aa843614bc2a97bc1dd3ccd2 (patch)
tree7ba25f9d556e11dcfd8a9fdbc663220e36de3f87
parent1fe5196b10fc30b1dfb8b4b0ac5bf2b6fa49c297 (diff)
downloadppp-883a65eee0ea9de6aa843614bc2a97bc1dd3ccd2.tar.gz
radius plugin: add fclose operation to fix file pointer not closed after use (#401)
Signed-off-by: Wei Xing <skyxwwalker@gmail.com> Co-authored-by: Wei Xing <skyxwwalker@gmail.com>
-rw-r--r--pppd/plugins/radius/clientid.c2
-rw-r--r--pppd/plugins/radius/config.c6
2 files changed, 8 insertions, 0 deletions
diff --git a/pppd/plugins/radius/clientid.c b/pppd/plugins/radius/clientid.c
index b1bbc47..eea5165 100644
--- a/pppd/plugins/radius/clientid.c
+++ b/pppd/plugins/radius/clientid.c
@@ -68,6 +68,7 @@ int rc_read_mapfile(char *filename)
if ((p = (struct map2id_s *)malloc(sizeof(*p))) == NULL) {
novm("rc_read_mapfile");
+ fclose(mapfd);
return (-1);
}
@@ -79,6 +80,7 @@ int rc_read_mapfile(char *filename)
} else {
error("rc_read_mapfile: malformed line in %s, line %d", filename, lnr);
+ fclose(mapfd);
return (-1);
}
diff --git a/pppd/plugins/radius/config.c b/pppd/plugins/radius/config.c
index 47c172c..39744fc 100644
--- a/pppd/plugins/radius/config.c
+++ b/pppd/plugins/radius/config.c
@@ -212,6 +212,7 @@ int rc_read_config(char *filename)
if ((pos = strcspn(p, "\t ")) == 0) {
error("%s: line %d: bogus format: %s", filename, line, p);
+ fclose(configfd);
return (-1);
}
@@ -224,6 +225,7 @@ int rc_read_config(char *filename)
if (option->status != ST_UNDEF) {
error("%s: line %d: duplicate option line: %s", filename, line, p);
+ fclose(configfd);
return (-1);
}
@@ -234,18 +236,22 @@ int rc_read_config(char *filename)
switch (option->type) {
case OT_STR:
if (set_option_str(filename, line, option, p) < 0)
+ fclose(configfd);
return (-1);
break;
case OT_INT:
if (set_option_int(filename, line, option, p) < 0)
+ fclose(configfd);
return (-1);
break;
case OT_SRV:
if (set_option_srv(filename, line, option, p) < 0)
+ fclose(configfd);
return (-1);
break;
case OT_AUO:
if (set_option_auo(filename, line, option, p) < 0)
+ fclose(configfd);
return (-1);
break;
default: