summaryrefslogtreecommitdiff
path: root/libs/libssh2/src/libssh2_priv.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libssh2/src/libssh2_priv.h')
-rw-r--r--libs/libssh2/src/libssh2_priv.h97
1 files changed, 79 insertions, 18 deletions
diff --git a/libs/libssh2/src/libssh2_priv.h b/libs/libssh2/src/libssh2_priv.h
index 96af134279..18d9ab2130 100644
--- a/libs/libssh2/src/libssh2_priv.h
+++ b/libs/libssh2/src/libssh2_priv.h
@@ -1,5 +1,5 @@
-#ifndef __LIBSSH2_PRIV_H
-#define __LIBSSH2_PRIV_H
+#ifndef LIBSSH2_PRIV_H
+#define LIBSSH2_PRIV_H
/* Copyright (C) Sara Golemon <sarag@libssh2.org>
* Copyright (C) Daniel Stenberg
* Copyright (C) Simon Josefsson
@@ -41,7 +41,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-/* Header used by 'src' */
+/* Header used by 'src' and 'tests' */
+
+/* FIXME: Disable warnings for 'src' */
+#if !defined(LIBSSH2_TESTS) && !defined(LIBSSH2_WARN_SIGN_CONVERSION)
+#ifdef __GNUC__
+#pragma GCC diagnostic ignored "-Wsign-conversion"
+#endif
+#endif
#define LIBSSH2_LIBRARY
@@ -86,6 +93,19 @@
#include "libssh2_sftp.h"
#include "misc.h"
+#ifdef _WIN32
+/* Detect Windows App environment which has a restricted access
+ to the Win32 APIs. */
+# if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
+ defined(WINAPI_FAMILY)
+# include <winapifamily.h>
+# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
+ !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+# define LIBSSH2_WINDOWS_UWP
+# endif
+# endif
+#endif
+
#ifndef FALSE
#define FALSE 0
#endif
@@ -93,12 +113,28 @@
#define TRUE 1
#endif
+#if (defined(__GNUC__) || defined(__clang__)) && \
+ defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \
+ !defined(LIBSSH2_NO_FMT_CHECKS)
+#ifdef __MINGW_PRINTF_FORMAT
+#define LIBSSH2_PRINTF(fmt, arg) \
+ __attribute__((format(__MINGW_PRINTF_FORMAT, fmt, arg)))
+#elif !defined(__MINGW32__)
+#define LIBSSH2_PRINTF(fmt, arg) \
+ __attribute__((format(printf, fmt, arg)))
+#endif
+#endif
+#ifndef LIBSSH2_PRINTF
+#define LIBSSH2_PRINTF(fmt, arg)
+#endif
+
/* Use local implementation when not available */
#if !defined(HAVE_SNPRINTF)
#undef snprintf
#define snprintf _libssh2_snprintf
#define LIBSSH2_SNPRINTF
-int _libssh2_snprintf(char *cp, size_t cp_max_len, const char *fmt, ...);
+int _libssh2_snprintf(char *cp, size_t cp_max_len, const char *fmt, ...)
+ LIBSSH2_PRINTF(3, 4);
#endif
#if !defined(HAVE_GETTIMEOFDAY)
@@ -111,6 +147,15 @@ int _libssh2_gettimeofday(struct timeval *tp, void *tzp);
#include <sys/time.h>
#endif
+#if !defined(LIBSSH2_FALLTHROUGH)
+#if (defined(__GNUC__) && __GNUC__ >= 7) || \
+ (defined(__clang__) && __clang_major__ >= 10)
+# define LIBSSH2_FALLTHROUGH() __attribute__((fallthrough))
+#else
+# define LIBSSH2_FALLTHROUGH() do {} while (0)
+#endif
+#endif
+
/* "inline" keyword is valid only with C++ engine! */
#ifdef __GNUC__
#undef inline
@@ -121,7 +166,7 @@ int _libssh2_gettimeofday(struct timeval *tp, void *tzp);
#endif
/* 3DS doesn't seem to have iovec */
-#if defined(WIN32) || defined(_3DS)
+#if defined(_WIN32) || defined(_3DS)
struct iovec {
size_t iov_len;
@@ -152,6 +197,9 @@ struct iovec {
#define LIBSSH2_MAX(x, y) ((x) > (y) ? (x) : (y))
#define LIBSSH2_MIN(x, y) ((x) < (y) ? (x) : (y))
+#define MAX_BLOCKSIZE 32 /* MUST fit biggest crypto block size we use/get */
+#define MAX_MACSIZE 64 /* MUST fit biggest MAC length we support */
+
/* RFC4253 section 6.1 Maximum Packet Length says:
*
* "All implementations MUST be able to process packets with
@@ -402,7 +450,7 @@ struct _LIBSSH2_CHANNEL
struct list_node node;
unsigned char *channel_type;
- unsigned channel_type_len;
+ size_t channel_type_len;
/* channel's program exit status */
int exit_status;
@@ -455,7 +503,7 @@ struct _LIBSSH2_CHANNEL
size_t flush_refund_bytes;
size_t flush_flush_bytes;
- /* State variables used in libssh2_channel_receive_window_adjust() */
+ /* State variables used in libssh2_channel_receive_window_adjust2() */
libssh2_nonblocking_states adjust_state;
unsigned char adjust_adjust[9]; /* packet_type(1) + channel(4) +
adjustment(4) */
@@ -688,6 +736,9 @@ struct _LIBSSH2_SESSION
/* key signing algorithm preferences -- NULL yields server order */
char *sign_algo_prefs;
+ /* Whether to use the OpenSSH Strict KEX extension */
+ int kex_strict;
+
/* (remote as source of data -- packet_read ) */
libssh2_endpoint_data remote;
@@ -710,7 +761,8 @@ struct _LIBSSH2_SESSION
int socket_state;
int socket_block_directions;
int socket_prev_blockstate; /* stores the state of the socket blockiness
- when libssh2_session_startup() is called */
+ when libssh2_session_handshake()
+ is called */
/* Error tracking */
const char *err_msg;
@@ -736,7 +788,7 @@ struct _LIBSSH2_SESSION
unsigned char *kexinit_data;
size_t kexinit_data_len;
- /* State variables used in libssh2_session_startup() */
+ /* State variables used in libssh2_session_handshake() */
libssh2_nonblocking_states startup_state;
unsigned char *startup_data;
size_t startup_data_len;
@@ -859,6 +911,7 @@ struct _LIBSSH2_SESSION
int fullpacket_macstate;
size_t fullpacket_payload_len;
int fullpacket_packet_type;
+ uint32_t fullpacket_required_type;
/* State variables used in libssh2_sftp_init() */
libssh2_nonblocking_states sftpInit_state;
@@ -869,7 +922,7 @@ struct _LIBSSH2_SESSION
size_t sftpInit_sent; /* number of bytes from the buffer that have been
sent */
- /* State variables used in libssh2_scp_recv() / libssh_scp_recv2() */
+ /* State variables used in libssh2_scp_recv2() */
libssh2_nonblocking_states scpRecv_state;
unsigned char *scpRecv_command;
size_t scpRecv_command_len;
@@ -899,10 +952,11 @@ struct _LIBSSH2_SESSION
};
/* session.state bits */
-#define LIBSSH2_STATE_EXCHANGING_KEYS 0x00000001
-#define LIBSSH2_STATE_NEWKEYS 0x00000002
-#define LIBSSH2_STATE_AUTHENTICATED 0x00000004
-#define LIBSSH2_STATE_KEX_ACTIVE 0x00000008
+#define LIBSSH2_STATE_INITIAL_KEX 0x00000001
+#define LIBSSH2_STATE_EXCHANGING_KEYS 0x00000002
+#define LIBSSH2_STATE_NEWKEYS 0x00000004
+#define LIBSSH2_STATE_AUTHENTICATED 0x00000008
+#define LIBSSH2_STATE_KEX_ACTIVE 0x00000010
/* session.flag helpers */
#ifdef MSG_NOSIGNAL
@@ -1032,7 +1086,7 @@ struct _LIBSSH2_COMP_METHOD
#ifdef LIBSSH2DEBUG
void
_libssh2_debug_low(LIBSSH2_SESSION * session, int context, const char *format,
- ...);
+ ...) LIBSSH2_PRINTF(3, 4);
#define _libssh2_debug(x) _libssh2_debug_low x
#else
#define _libssh2_debug(x) do {} while(0)
@@ -1133,6 +1187,11 @@ ssize_t _libssh2_send(libssh2_socket_t socket, const void *buffer,
int _libssh2_kex_exchange(LIBSSH2_SESSION * session, int reexchange,
key_exchange_state_t * state);
+unsigned char *_libssh2_kex_agree_instr(unsigned char *haystack,
+ size_t haystack_len,
+ const unsigned char *needle,
+ size_t needle_len);
+
/* Let crypt.c/hostkey.c expose their method structs */
const LIBSSH2_CRYPT_METHOD **libssh2_crypt_methods(void);
const LIBSSH2_HOSTKEY_METHOD **libssh2_hostkey_methods(void);
@@ -1182,6 +1241,8 @@ size_t plain_method(char *method, size_t method_len);
/* define to output the libssh2_int64_t type in a *printf() */
#if defined(__BORLANDC__) || defined(_MSC_VER)
#define LIBSSH2_INT64_T_FORMAT "I64d"
+#elif defined(__MINGW32__)
+#define LIBSSH2_INT64_T_FORMAT PRId64
#else
#define LIBSSH2_INT64_T_FORMAT "lld"
#endif
@@ -1189,12 +1250,12 @@ size_t plain_method(char *method, size_t method_len);
/* In Windows the default file mode is text but an application can override it.
Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
*/
-#if defined(WIN32) || defined(MSDOS)
+#if defined(_WIN32) || defined(MSDOS)
#define FOPEN_READTEXT "rt"
#define FOPEN_WRITETEXT "wt"
#define FOPEN_APPENDTEXT "at"
#elif defined(__CYGWIN__)
-/* Cygwin has specific behavior we need to address when WIN32 is not defined.
+/* Cygwin has specific behavior we need to address when _WIN32 is not defined.
https://cygwin.com/cygwin-ug-net/using-textbinary.html
For write we want our output to have line endings of LF and be compatible
with other Cygwin utilities. For read we want to handle input that may have
@@ -1209,4 +1270,4 @@ size_t plain_method(char *method, size_t method_len);
#define FOPEN_APPENDTEXT "a"
#endif
-#endif /* __LIBSSH2_PRIV_H */
+#endif /* LIBSSH2_PRIV_H */