backport upstream patches

This commit is contained in:
xinghe 2022-10-13 03:05:26 +00:00
parent 578e8a5b66
commit e3a32ffac4
5 changed files with 172 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From bb5f7e2707c1d04cd080bc64ff748ec89cf614fa Mon Sep 17 00:00:00 2001
From: Norbert Pocs <npocs@redhat.com>
Date: Mon, 4 Jul 2022 13:58:06 +0200
Subject: options: Parse hostname by last '@'
The login name can have '@' char in it
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Conflict:NA
Reference:https://git.libssh.org/projects/libssh.git/patch/?id=bb5f7e2707c1d04cd080bc64ff748ec89cf614fa
---
src/options.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/options.c b/src/options.c
index e4c80f8..9c2ac29 100644
--- a/src/options.c
+++ b/src/options.c
@@ -495,7 +495,7 @@ int ssh_options_set(ssh_session session, enum ssh_options_e type,
ssh_set_error_oom(session);
return -1;
}
- p = strchr(q, '@');
+ p = strrchr(q, '@');
SAFE_FREE(session->opts.host);
--
2.33.0

View File

@ -0,0 +1,31 @@
From 355e29d881dcf2d255fbe58864ef98dc3bc5653c Mon Sep 17 00:00:00 2001
From: Jakub Jelen <jjelen@redhat.com>
Date: Mon, 4 Jul 2022 19:22:30 +0200
Subject: session: Initialize pointers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Conflict:NA
Reference:https://git.libssh.org/projects/libssh.git/patch/?id=355e29d881dcf2d255fbe58864ef98dc3bc5653c
---
src/session.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/session.c b/src/session.c
index 3199096..484fe39 100644
--- a/src/session.c
+++ b/src/session.c
@@ -977,7 +977,7 @@ int ssh_get_pubkey_hash(ssh_session session, unsigned char **hash)
ssh_key pubkey = NULL;
ssh_string pubkey_blob = NULL;
MD5CTX ctx;
- unsigned char *h;
+ unsigned char *h = NULL;
int rc;
if (session == NULL || hash == NULL) {
--
2.33.0

View File

@ -0,0 +1,57 @@
From 1286a70e139fb7553dce02107cdcdf36edcf53f1 Mon Sep 17 00:00:00 2001
From: renmingshuai <renmingshuai@huawei.com>
Date: Fri, 5 Aug 2022 17:08:30 +0800
Subject: tests: Ensure the mode of the created file is ...
what we set in open funtion by the argument mode. The mode of the
created file
is (mode & ~umask), So we set umask to typical default value(octal 022).
Signed-off-by: renmingshuai <renmingshuai@huawei.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Conflict:NA
Reference:https://git.libssh.org/projects/libssh.git/patch/?id=1286a70e139fb7553dce02107cdcdf36edcf53f1
---
tests/client/torture_scp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tests/client/torture_scp.c b/tests/client/torture_scp.c
index 59a00ba..fe3f239 100644
--- a/tests/client/torture_scp.c
+++ b/tests/client/torture_scp.c
@@ -39,6 +39,9 @@
#define TEMPLATE BINARYDIR "/tests/home/alice/temp_dir_XXXXXX"
#define ALICE_HOME BINARYDIR "/tests/home/alice"
+/* store the original umask */
+mode_t old;
+
struct scp_st {
struct torture_state *s;
char *tmp_dir;
@@ -99,6 +102,9 @@ static int session_setup(void **state)
s = ts->s;
+ /* store the original umask and set a new one */
+ old = umask(0022);
+
/* Create temporary directory for alice */
tmp_dir = torture_make_temp_dir(TEMPLATE);
assert_non_null(tmp_dir);
@@ -135,6 +141,9 @@ static int session_teardown(void **state)
assert_non_null(ts->s);
s = ts->s;
+ /* restore the umask */
+ umask(old);
+
ssh_disconnect(s->ssh.session);
ssh_free(s->ssh.session);
--
2.33.0

View File

@ -0,0 +1,37 @@
From 964df4dc290c631fe2ece74600e510ca6c0a7385 Mon Sep 17 00:00:00 2001
From: Norbert Pocs <npocs@redhat.com>
Date: Mon, 11 Jul 2022 12:34:34 +0200
Subject: torture_options: Add test for '@' in login name
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Conflict:NA
Reference:https://git.libssh.org/projects/libssh.git/commit?id=964df4dc290c631fe2ece74600e510ca6c0a7385
---
tests/unittests/torture_options.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tests/unittests/torture_options.c b/tests/unittests/torture_options.c
index d0fdaed..6bfd091 100644
--- a/tests/unittests/torture_options.c
+++ b/tests/unittests/torture_options.c
@@ -65,6 +65,13 @@ static void torture_options_set_host(void **state) {
assert_string_equal(session->opts.host, "meditation");
assert_non_null(session->opts.username);
assert_string_equal(session->opts.username, "guru");
+
+ rc = ssh_options_set(session, SSH_OPTIONS_HOST, "at@login@hostname");
+ assert_true(rc == 0);
+ assert_non_null(session->opts.host);
+ assert_string_equal(session->opts.host, "hostname");
+ assert_non_null(session->opts.username);
+ assert_string_equal(session->opts.username, "at@login");
}
static void torture_options_set_ciphers(void **state) {
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: libssh
Version: 0.9.6
Release: 3
Release: 4
Summary: A library implementing the SSH protocol
License: LGPLv2+
URL: http://www.libssh.org
@ -14,6 +14,10 @@ Patch1: backport-client-Do-not-close-the-socket-if-it-was-set-via-opt.pa
Patch2: backport-libsshpp-Fix-openForward-to-not-set-sourcehost-to-NU.patch
Patch3: backport-auth-Fix-error-returned-in-ssh_userauth_try_publicke.patch
Patch4: backport-sftp-fix-the-length-calculation-of-packet-in-sftp_wr.patch
Patch5: backport-options-Parse-hostname-by-last.patch
Patch6: backport-torture_options-Add-test-for-in-login-name.patch
Patch7: backport-session-Initialize-pointers.patch
Patch8: backport-tests-Ensure-the-mode-of-the-created-file-is.patch
BuildRequires: cmake gcc-c++ gnupg2 openssl-devel pkgconfig zlib-devel
BuildRequires: krb5-devel libcmocka-devel openssh-clients openssh-server
@ -99,6 +103,15 @@ popd
%doc ChangeLog README
%changelog
* Thu Oct 13 2022 xinghe <xinghe2@h-partners.com> - 0.9.6-4
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:options: Parse hostname by last '@'
torture_options: Add test for '@' in login name
session: Initialize pointers
tests: Ensure the mode of the created file is what we set
* Fri Sep 02 2022 gaihuiying <eaglegai@163.com> - 0.9.6-3
- Type:bugfix
- Id:NA