Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/crypto/external/bsd/openssh/dist/authfile.c,v rcsdiff: /ftp/cvs/cvsroot/src/crypto/external/bsd/openssh/dist/authfile.c,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.17 retrieving revision 1.17.2.2 diff -u -p -r1.17 -r1.17.2.2 --- src/crypto/external/bsd/openssh/dist/authfile.c 2017/10/07 19:39:19 1.17 +++ src/crypto/external/bsd/openssh/dist/authfile.c 2018/09/06 06:51:33 1.17.2.2 @@ -1,5 +1,6 @@ -/* $NetBSD: authfile.c,v 1.17 2017/10/07 19:39:19 christos Exp $ */ -/* $OpenBSD: authfile.c,v 1.127 2017/07/01 13:50:45 djm Exp $ */ +/* $NetBSD: authfile.c,v 1.17.2.2 2018/09/06 06:51:33 pgoyette Exp $ */ +/* $OpenBSD: authfile.c,v 1.130 2018/07/09 21:59:10 markus Exp $ */ + /* * Copyright (c) 2000, 2013 Markus Friedl. All rights reserved. * @@ -25,7 +26,7 @@ */ #include "includes.h" -__RCSID("$NetBSD: authfile.c,v 1.17 2017/10/07 19:39:19 christos Exp $"); +__RCSID("$NetBSD: authfile.c,v 1.17.2.2 2018/09/06 06:51:33 pgoyette Exp $"); #include #include #include @@ -59,7 +60,7 @@ sshkey_save_private_blob(struct sshbuf * if ((fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0600)) < 0) return SSH_ERR_SYSTEM_ERROR; - if (atomicio(vwrite, fd, __UNCONST(sshbuf_ptr(keybuf)), + if (atomicio(vwrite, fd, sshbuf_mutable_ptr(keybuf), sshbuf_len(keybuf)) != sshbuf_len(keybuf)) { oerrno = errno; close(fd); @@ -188,6 +189,8 @@ sshkey_load_private_type(int type, const *perm_ok = 1; r = sshkey_load_private_type_fd(fd, type, passphrase, keyp, commentp); + if (r == 0 && keyp && *keyp) + r = sshkey_set_filename(*keyp, filename); out: close(fd); return r; @@ -246,6 +249,9 @@ sshkey_load_private(const char *filename (r = sshkey_parse_private_fileblob(buffer, passphrase, keyp, commentp)) != 0) goto out; + if (keyp && *keyp && + (r = sshkey_set_filename(*keyp, filename)) != 0) + goto out; r = 0; out: close(fd); @@ -257,17 +263,15 @@ static int sshkey_try_load_public(struct sshkey *k, const char *filename, char **commentp) { FILE *f; - char line[SSH_MAX_PUBKEY_BYTES]; - char *cp; - u_long linenum = 0; + char *line = NULL, *cp; + size_t linesize = 0; int r; if (commentp != NULL) *commentp = NULL; if ((f = fopen(filename, "r")) == NULL) return SSH_ERR_SYSTEM_ERROR; - while (read_keyfile_line(f, filename, line, sizeof(line), - &linenum) != -1) { + while (getline(&line, &linesize, f) != -1) { cp = line; switch (*cp) { case '#': @@ -291,11 +295,13 @@ sshkey_try_load_public(struct sshkey *k, if (*commentp == NULL) r = SSH_ERR_ALLOC_FAIL; } + free(line); fclose(f); return r; } } } + free(line); fclose(f); return SSH_ERR_INVALID_FORMAT; } @@ -394,6 +400,7 @@ sshkey_load_private_cert(int type, const case KEY_ECDSA: #endif /* WITH_OPENSSL */ case KEY_ED25519: + case KEY_XMSS: case KEY_UNSPEC: break; default: @@ -438,19 +445,18 @@ sshkey_in_file(struct sshkey *key, const int check_ca) { FILE *f; - char line[SSH_MAX_PUBKEY_BYTES]; - char *cp; - u_long linenum = 0; + char *line = NULL, *cp; + size_t linesize = 0; int r = 0; struct sshkey *pub = NULL; + int (*sshkey_compare)(const struct sshkey *, const struct sshkey *) = strict_type ? sshkey_equal : sshkey_equal_public; if ((f = fopen(filename, "r")) == NULL) return SSH_ERR_SYSTEM_ERROR; - while (read_keyfile_line(f, filename, line, sizeof(line), - &linenum) != -1) { + while (getline(&line, &linesize, f) != -1) { cp = line; /* Skip leading whitespace. */ @@ -482,6 +488,7 @@ sshkey_in_file(struct sshkey *key, const } r = SSH_ERR_KEY_NOT_FOUND; out: + free(line); sshkey_free(pub); fclose(f); return r;