diff options
Diffstat (limited to 'src/lib/libtls/tls_config.c')
| -rw-r--r-- | src/lib/libtls/tls_config.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/libtls/tls_config.c b/src/lib/libtls/tls_config.c index e2e3f4abaa..d44b8dde49 100644 --- a/src/lib/libtls/tls_config.c +++ b/src/lib/libtls/tls_config.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: tls_config.c,v 1.45 2017/12/09 16:46:08 jsing Exp $ */ | 1 | /* $OpenBSD: tls_config.c,v 1.46 2018/02/05 00:52:24 jsing Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
| 4 | * | 4 | * |
| @@ -161,31 +161,31 @@ tls_config_load_file(struct tls_error *error, const char *filetype, | |||
| 161 | if ((fd = open(filename, O_RDONLY)) == -1) { | 161 | if ((fd = open(filename, O_RDONLY)) == -1) { |
| 162 | tls_error_set(error, "failed to open %s file '%s'", | 162 | tls_error_set(error, "failed to open %s file '%s'", |
| 163 | filetype, filename); | 163 | filetype, filename); |
| 164 | goto fail; | 164 | goto err; |
| 165 | } | 165 | } |
| 166 | if (fstat(fd, &st) != 0) { | 166 | if (fstat(fd, &st) != 0) { |
| 167 | tls_error_set(error, "failed to stat %s file '%s'", | 167 | tls_error_set(error, "failed to stat %s file '%s'", |
| 168 | filetype, filename); | 168 | filetype, filename); |
| 169 | goto fail; | 169 | goto err; |
| 170 | } | 170 | } |
| 171 | if (st.st_size < 0) | 171 | if (st.st_size < 0) |
| 172 | goto fail; | 172 | goto err; |
| 173 | *len = (size_t)st.st_size; | 173 | *len = (size_t)st.st_size; |
| 174 | if ((*buf = malloc(*len)) == NULL) { | 174 | if ((*buf = malloc(*len)) == NULL) { |
| 175 | tls_error_set(error, "failed to allocate buffer for " | 175 | tls_error_set(error, "failed to allocate buffer for " |
| 176 | "%s file", filetype); | 176 | "%s file", filetype); |
| 177 | goto fail; | 177 | goto err; |
| 178 | } | 178 | } |
| 179 | n = read(fd, *buf, *len); | 179 | n = read(fd, *buf, *len); |
| 180 | if (n < 0 || (size_t)n != *len) { | 180 | if (n < 0 || (size_t)n != *len) { |
| 181 | tls_error_set(error, "failed to read %s file '%s'", | 181 | tls_error_set(error, "failed to read %s file '%s'", |
| 182 | filetype, filename); | 182 | filetype, filename); |
| 183 | goto fail; | 183 | goto err; |
| 184 | } | 184 | } |
| 185 | close(fd); | 185 | close(fd); |
| 186 | return 0; | 186 | return 0; |
| 187 | 187 | ||
| 188 | fail: | 188 | err: |
| 189 | if (fd != -1) | 189 | if (fd != -1) |
| 190 | close(fd); | 190 | close(fd); |
| 191 | freezero(*buf, *len); | 191 | freezero(*buf, *len); |
| @@ -571,17 +571,17 @@ tls_config_set_ciphers(struct tls_config *config, const char *ciphers) | |||
| 571 | 571 | ||
| 572 | if ((ssl_ctx = SSL_CTX_new(SSLv23_method())) == NULL) { | 572 | if ((ssl_ctx = SSL_CTX_new(SSLv23_method())) == NULL) { |
| 573 | tls_config_set_errorx(config, "out of memory"); | 573 | tls_config_set_errorx(config, "out of memory"); |
| 574 | goto fail; | 574 | goto err; |
| 575 | } | 575 | } |
| 576 | if (SSL_CTX_set_cipher_list(ssl_ctx, ciphers) != 1) { | 576 | if (SSL_CTX_set_cipher_list(ssl_ctx, ciphers) != 1) { |
| 577 | tls_config_set_errorx(config, "no ciphers for '%s'", ciphers); | 577 | tls_config_set_errorx(config, "no ciphers for '%s'", ciphers); |
| 578 | goto fail; | 578 | goto err; |
| 579 | } | 579 | } |
| 580 | 580 | ||
| 581 | SSL_CTX_free(ssl_ctx); | 581 | SSL_CTX_free(ssl_ctx); |
| 582 | return set_string(&config->ciphers, ciphers); | 582 | return set_string(&config->ciphers, ciphers); |
| 583 | 583 | ||
| 584 | fail: | 584 | err: |
| 585 | SSL_CTX_free(ssl_ctx); | 585 | SSL_CTX_free(ssl_ctx); |
| 586 | return -1; | 586 | return -1; |
| 587 | } | 587 | } |
