From 63b4c20eb031227d040a3aca3224c80189411464 Mon Sep 17 00:00:00 2001From: renmingshuai <renmingshuai@huawei.com>Date: Tue, 1 Aug 2023 12:36:24 +0800Subject: [PATCH] Add a new structure to separate memory read and file read. Weuse different APIs when we read one private key from memory, so it isimproper to store the private key information in the structure that storesthe private key file information.Fixes https://github.com/libssh2/libssh2/issues/773Reported-by: mike-jumperReference:https://github.com/libssh2/libssh2/commit/63b4c20eb031227d040a3aca3224c80189411464Conflict:NA---src/userauth.c | 23 +++++++++++++++--------1 file changed, 15 insertions(+), 8 deletions(-)diff --git a/src/userauth.c b/src/userauth.cindex 5ce4ccb1..c382e661 100644--- a/src/userauth.c+++ b/src/userauth.c@@ -818,11 +818,17 @@ struct privkey_file {const char *passphrase;};+struct privkey_mem {+ const char *passphrase;+ const char *data;+ size_t data_len;+};+static intsign_frommemory(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,const unsigned char *data, size_t data_len, void **abstract){- struct privkey_file *pk_file = (struct privkey_file *) (*abstract);+ struct privkey_mem *pk_mem = (struct privkey_mem *) (*abstract);const LIBSSH2_HOSTKEY_METHOD *privkeyobj;void *hostkey_abstract;struct iovec datavec;@@ -831,9 +837,9 @@ sign_frommemory(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,rc = memory_read_privatekey(session, &privkeyobj, &hostkey_abstract,session->userauth_pblc_method,session->userauth_pblc_method_len,- pk_file->filename,- strlen(pk_file->filename),- pk_file->passphrase);+ pk_mem->data,+ pk_mem->data_len,+ pk_mem->passphrase);if(rc)return rc;@@ -1835,12 +1841,13 @@ userauth_publickey_frommemory(LIBSSH2_SESSION *session,{unsigned char *pubkeydata = NULL;size_t pubkeydata_len = 0;- struct privkey_file privkey_file;- void *abstract = &privkey_file;+ struct privkey_mem privkey_mem;+ void *abstract = &privkey_mem;int rc;- privkey_file.filename = privatekeydata;- privkey_file.passphrase = passphrase;+ privkey_mem.data = privatekeydata;+ privkey_mem.data_len = privatekeydata_len;+ privkey_mem.passphrase = passphrase;if(session->userauth_pblc_state == libssh2_NB_state_idle) {if(publickeydata_len && publickeydata) {--2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型