]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: ssl: close ssl key file on error
authormildis <me@mildis.org>
Wed, 22 Jun 2016 15:46:29 +0000 (17:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 24 Jun 2016 13:27:30 +0000 (15:27 +0200)
Explicitly close the FILE opened to read the ssl key file when parsing
fails to find a valid key.

This fix needs to be backported to 1.6.

src/ssl_sock.c

index 6635d5c848692606569aa469c6412bcd447e2ff7..88d74d2495f57fb3c2a55529957ac08ea50a3c94 100644 (file)
@@ -5401,6 +5401,7 @@ static int bind_parse_tls_ticket_keys(char **args, int cur_arg, struct proxy *px
                if (base64dec(thisline, len, (char *) (keys_ref->tlskeys + i % TLS_TICKETS_NO), sizeof(struct tls_sess_key)) != sizeof(struct tls_sess_key)) {
                        if (err)
                                memprintf(err, "'%s' : unable to decode base64 key on line %d", args[cur_arg+1], i + 1);
+                       fclose(f);
                        return ERR_ALERT | ERR_FATAL;
                }
                i++;
@@ -5409,6 +5410,7 @@ static int bind_parse_tls_ticket_keys(char **args, int cur_arg, struct proxy *px
        if (i < TLS_TICKETS_NO) {
                if (err)
                        memprintf(err, "'%s' : please supply at least %d keys in the tls-tickets-file", args[cur_arg+1], TLS_TICKETS_NO);
+               fclose(f);
                return ERR_ALERT | ERR_FATAL;
        }