]> git.ozlabs.org Git - ppp.git/commitdiff
radius plugin: add fclose operation to fix file pointer not closed after use (#401)
authorBmo <35866749+XWwalker@users.noreply.github.com>
Fri, 17 Mar 2023 22:20:43 +0000 (06:20 +0800)
committerGitHub <noreply@github.com>
Fri, 17 Mar 2023 22:20:43 +0000 (09:20 +1100)
Signed-off-by: Wei Xing <skyxwwalker@gmail.com>
Co-authored-by: Wei Xing <skyxwwalker@gmail.com>
pppd/plugins/radius/clientid.c
pppd/plugins/radius/config.c

index b1bbc4748ed9794f6ae3af328697854f97fe4eeb..eea516505d730436569aa0070ec197d9be4fbf0f 100644 (file)
@@ -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);
 
                }
index 47c172cccf00234b9bcc135a63a14e9a30c7006b..39744fca12f04730a4e69f9e8f293f258b63162e 100644 (file)
@@ -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: