diff options
author | djm@openbsd.org <djm@openbsd.org> | 2020-01-26 00:02:13 +0100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2020-01-26 00:18:42 +0100 |
commit | 99aa8035554ddb976348d2a9253ab3653019728d (patch) | |
tree | 195dc658a883d04305334be9658ba7b9eba55e94 /krl.c | |
parent | upstream: add a comment describing the ranges of channel IDs that (diff) | |
download | openssh-99aa8035554ddb976348d2a9253ab3653019728d.tar.xz openssh-99aa8035554ddb976348d2a9253ab3653019728d.zip |
upstream: factor out reading/writing sshbufs to dedicated
functions; feedback and ok markus@
OpenBSD-Commit-ID: dc09e5f1950b7acc91b8fdf8015347782d2ecd3d
Diffstat (limited to 'krl.c')
-rw-r--r-- | krl.c | 16 |
1 files changed, 3 insertions, 13 deletions
@@ -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) |