From 99aa8035554ddb976348d2a9253ab3653019728d Mon Sep 17 00:00:00 2001 From: "djm@openbsd.org" Date: Sat, 25 Jan 2020 23:02:13 +0000 Subject: upstream: factor out reading/writing sshbufs to dedicated functions; feedback and ok markus@ OpenBSD-Commit-ID: dc09e5f1950b7acc91b8fdf8015347782d2ecd3d --- krl.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'krl.c') diff --git a/krl.c b/krl.c index aa8318cf1..03476dedd 100644 --- a/krl.c +++ b/krl.c @@ -14,7 +14,7 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $OpenBSD: krl.c,v 1.46 2019/11/25 00:51:37 djm Exp $ */ +/* $OpenBSD: krl.c,v 1.47 2020/01/25 23:02:13 djm Exp $ */ #include "includes.h" @@ -1336,19 +1336,11 @@ ssh_krl_file_contains_key(const char *path, const struct sshkey *key) { struct sshbuf *krlbuf = NULL; struct ssh_krl *krl = NULL; - int oerrno = 0, r, fd; + int oerrno = 0, r; if (path == NULL) return 0; - - if ((krlbuf = sshbuf_new()) == NULL) - return SSH_ERR_ALLOC_FAIL; - if ((fd = open(path, O_RDONLY)) == -1) { - r = SSH_ERR_SYSTEM_ERROR; - oerrno = errno; - goto out; - } - if ((r = sshkey_load_file(fd, krlbuf)) != 0) { + if ((r = sshbuf_load_file(path, &krlbuf)) != 0) { oerrno = errno; goto out; } @@ -1357,8 +1349,6 @@ ssh_krl_file_contains_key(const char *path, const struct sshkey *key) debug2("%s: checking KRL %s", __func__, path); r = ssh_krl_check_key(krl, key); out: - if (fd != -1) - close(fd); sshbuf_free(krlbuf); ssh_krl_free(krl); if (r != 0) -- cgit v1.2.3