summaryrefslogtreecommitdiff
path: root/krl.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-01-25 23:02:13 +0000
committerDamien Miller <djm@mindrot.org>2020-01-26 10:18:42 +1100
commit99aa8035554ddb976348d2a9253ab3653019728d (patch)
tree195dc658a883d04305334be9658ba7b9eba55e94 /krl.c
parent065064fcf455778b0918f783033b374d4ba37a92 (diff)
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.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/krl.c b/krl.c
index aa8318cf1..03476dedd 100644
--- a/krl.c
+++ b/krl.c
@@ -14,7 +14,7 @@
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */ 15 */
16 16
17/* $OpenBSD: krl.c,v 1.46 2019/11/25 00:51:37 djm Exp $ */ 17/* $OpenBSD: krl.c,v 1.47 2020/01/25 23:02:13 djm Exp $ */
18 18
19#include "includes.h" 19#include "includes.h"
20 20
@@ -1336,19 +1336,11 @@ ssh_krl_file_contains_key(const char *path, const struct sshkey *key)
1336{ 1336{
1337 struct sshbuf *krlbuf = NULL; 1337 struct sshbuf *krlbuf = NULL;
1338 struct ssh_krl *krl = NULL; 1338 struct ssh_krl *krl = NULL;
1339 int oerrno = 0, r, fd; 1339 int oerrno = 0, r;
1340 1340
1341 if (path == NULL) 1341 if (path == NULL)
1342 return 0; 1342 return 0;
1343 1343 if ((r = sshbuf_load_file(path, &krlbuf)) != 0) {
1344 if ((krlbuf = sshbuf_new()) == NULL)
1345 return SSH_ERR_ALLOC_FAIL;
1346 if ((fd = open(path, O_RDONLY)) == -1) {
1347 r = SSH_ERR_SYSTEM_ERROR;
1348 oerrno = errno;
1349 goto out;
1350 }
1351 if ((r = sshkey_load_file(fd, krlbuf)) != 0) {
1352 oerrno = errno; 1344 oerrno = errno;
1353 goto out; 1345 goto out;
1354 } 1346 }
@@ -1357,8 +1349,6 @@ ssh_krl_file_contains_key(const char *path, const struct sshkey *key)
1357 debug2("%s: checking KRL %s", __func__, path); 1349 debug2("%s: checking KRL %s", __func__, path);
1358 r = ssh_krl_check_key(krl, key); 1350 r = ssh_krl_check_key(krl, key);
1359 out: 1351 out:
1360 if (fd != -1)
1361 close(fd);
1362 sshbuf_free(krlbuf); 1352 sshbuf_free(krlbuf);
1363 ssh_krl_free(krl); 1353 ssh_krl_free(krl);
1364 if (r != 0) 1354 if (r != 0)