* build: enable '-pedantic-errors' * build: add 'LIBSSH2_NO_DEPRECATED' option * build: stop requiring libssl from openssl * disable DSA by default * hostkey: do not advertise ssh-rsa when SHA1 is disabled * kex: prevent possible double free of hostkey * kex: always check for null pointers before calling _libssh2_bn_set_word * kex: fix a memory leak in key exchange * kex: always add extension indicators to kex_algorithms * md5: allow disabling old-style encrypted private keys at build-time * openssl: free allocated resources when using openssl3 * openssl: fix memory leaks in '_libssh2_ecdsa_curve_name_with_octal_new' and '_libssh2_ecdsa_verify' * openssl: fix calculating DSA public key with OpenSSL 3 * openssl: initialize BIGNUMs to NULL in 'gen_publickey_from_dsa' for OpenSSL 3 * openssl: fix cppcheck found NULL dereferences * openssl: delete internal 'read_openssh_private_key_from_memory()' * openssl: use OpenSSL 3 HMAC API, add 'no-deprecated' CI job * openssl: make a function static, add '#ifdef' comments * openssl: fix DSA code to use OpenSSL 3 API * openssl: fix 'EC_KEY' reference with OpenSSL 3 'no-deprecated' build * openssl: use non-deprecated APIs with OpenSSL 3.x * openssl: silence '-Wunused-value' warnings * openssl: add missing check for 'LIBRESSL_VERSION_NUMBER' before use * packet: properly bounds check packet_authagent_open() * pem: fix private keys encrypted with AES-GCM methods * reuse: provide SPDX identifiers * scp: fix missing cast for targets without large file support * session: support server banners up to 8192 bytes OBS-URL: https://build.opensuse.org/package/show/devel:libraries:c_c++/libssh2_org?expand=0&rev=79
73 lines
3.0 KiB
Diff
73 lines
3.0 KiB
Diff
From 33a59a1905feb5d786e9d457f287dd9e81a9f747 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= <crrodriguez@opensuse.org>
|
|
Date: Tue, 27 Dec 2011 00:33:28 -0300
|
|
Subject: [PATCH] Use O_CLOEXEC where needed
|
|
|
|
---
|
|
src/agent.c | 2 +-
|
|
src/knownhost.c | 4 ++--
|
|
src/userauth.c | 2 +-
|
|
3 files changed, 4 insertions(+), 4 deletions(-)
|
|
|
|
Index: libssh2-1.11.1/src/agent.c
|
|
===================================================================
|
|
--- libssh2-1.11.1.orig/src/agent.c
|
|
+++ libssh2-1.11.1/src/agent.c
|
|
@@ -183,7 +183,7 @@ agent_connect_unix(LIBSSH2_AGENT *agent)
|
|
"no auth sock variable");
|
|
}
|
|
|
|
- agent->fd = socket(PF_UNIX, SOCK_STREAM, 0);
|
|
+ agent->fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
|
if(agent->fd < 0)
|
|
return _libssh2_error(agent->session, LIBSSH2_ERROR_BAD_SOCKET,
|
|
"failed creating socket");
|
|
Index: libssh2-1.11.1/src/knownhost.c
|
|
===================================================================
|
|
--- libssh2-1.11.1.orig/src/knownhost.c
|
|
+++ libssh2-1.11.1/src/knownhost.c
|
|
@@ -970,7 +970,7 @@ libssh2_knownhost_readfile(LIBSSH2_KNOWN
|
|
"Unsupported type of known-host information "
|
|
"store");
|
|
|
|
- file = fopen(filename, FOPEN_READTEXT);
|
|
+ file = fopen(filename, FOPEN_READTEXT_CLOEXEC);
|
|
if(file) {
|
|
while(fgets(buf, sizeof(buf), file)) {
|
|
if(libssh2_knownhost_readline(hosts, buf, strlen(buf), type)) {
|
|
@@ -1213,7 +1213,7 @@ libssh2_knownhost_writefile(LIBSSH2_KNOW
|
|
"Unsupported type of known-host information "
|
|
"store");
|
|
|
|
- file = fopen(filename, FOPEN_WRITETEXT);
|
|
+ file = fopen(filename, FOPEN_WRITETEXT_CLOEXEC);
|
|
if(!file)
|
|
return _libssh2_error(hosts->session, LIBSSH2_ERROR_FILE,
|
|
"Failed to open file");
|
|
Index: libssh2-1.11.1/src/userauth.c
|
|
===================================================================
|
|
--- libssh2-1.11.1.orig/src/userauth.c
|
|
+++ libssh2-1.11.1/src/userauth.c
|
|
@@ -658,7 +658,7 @@ file_read_publickey(LIBSSH2_SESSION * se
|
|
_libssh2_debug((session, LIBSSH2_TRACE_AUTH, "Loading public key file: %s",
|
|
pubkeyfile));
|
|
/* Read Public Key */
|
|
- fd = fopen(pubkeyfile, FOPEN_READTEXT);
|
|
+ fd = fopen(pubkeyfile, FOPEN_READTEXT_CLOEXEC);
|
|
if(!fd) {
|
|
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
|
"Unable to open public key file");
|
|
Index: libssh2-1.11.1/src/libssh2_priv.h
|
|
===================================================================
|
|
--- libssh2-1.11.1.orig/src/libssh2_priv.h
|
|
+++ libssh2-1.11.1/src/libssh2_priv.h
|
|
@@ -1278,6 +1278,8 @@ size_t plain_method(char *method, size_t
|
|
#define FOPEN_READTEXT "r"
|
|
#define FOPEN_WRITETEXT "w"
|
|
#define FOPEN_APPENDTEXT "a"
|
|
+#define FOPEN_READTEXT_CLOEXEC "re"
|
|
+#define FOPEN_WRITETEXT_CLOEXEC "we"
|
|
#endif
|
|
|
|
#endif /* LIBSSH2_PRIV_H */
|