summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2015-06-04 22:25:28 +0800
committerMatt Johnston <matt@ucc.asn.au>2015-06-04 22:25:28 +0800
commitc0e5fca0bd82e13dce2eb4c64eaf85d427e33608 (patch)
tree9ff267aac129ef25bcaebc64e0380289021d2249
parentc2d635948fc1590778e838f5e724a93c0f02817c (diff)
parentd27f071b2daa5b7bd5d97d6f296eed1d1158d155 (diff)
downloaddropbear-c0e5fca0bd82e13dce2eb4c64eaf85d427e33608.tar.gz
Merge pull request #13 from gazoo74/fix-warnings
Fix warnings
-rw-r--r--cli-runopts.c7
-rw-r--r--cli-session.c2
-rw-r--r--common-algo.c3
-rw-r--r--common-session.c2
-rw-r--r--netio.c41
-rw-r--r--netio.h2
-rw-r--r--options.h9
-rw-r--r--svr-authpasswd.c2
-rw-r--r--svr-main.c2
-rw-r--r--svr-session.c2
-rw-r--r--sysoptions.h7
11 files changed, 51 insertions, 28 deletions
diff --git a/cli-runopts.c b/cli-runopts.c
index 467776b..5bd4c55 100644
--- a/cli-runopts.c
+++ b/cli-runopts.c
@@ -447,7 +447,7 @@ void cli_getopts(int argc, char ** argv) {
}
#endif
-#ifdef DROPBEAR_DEFAULT_CLI_AUTHKEY
+#if defined(DROPBEAR_DEFAULT_CLI_AUTHKEY) && defined(ENABLE_CLI_PUBKEY_AUTH)
{
char *expand_path = expand_tilde(DROPBEAR_DEFAULT_CLI_AUTHKEY);
loadidentityfile(expand_path, 0);
@@ -498,11 +498,14 @@ multihop_passthrough_args() {
m_list_elem *iter;
/* Fill out -i, -y, -W options that make sense for all
* the intermediate processes */
+#ifdef ENABLE_CLI_PUBKEY_AUTH
for (iter = cli_opts.privkeys->first; iter; iter = iter->next)
{
sign_key * key = (sign_key*)iter->item;
len += 3 + strlen(key->filename);
}
+#endif /* ENABLE_CLI_PUBKEY_AUTH */
+
len += 30; /* space for -W <size>, terminator. */
ret = m_malloc(len);
total = 0;
@@ -524,6 +527,7 @@ multihop_passthrough_args() {
total += written;
}
+#ifdef ENABLE_CLI_PUBKEY_AUTH
for (iter = cli_opts.privkeys->first; iter; iter = iter->next)
{
sign_key * key = (sign_key*)iter->item;
@@ -532,6 +536,7 @@ multihop_passthrough_args() {
dropbear_assert((unsigned int)written < size);
total += written;
}
+#endif /* ENABLE_CLI_PUBKEY_AUTH */
/* if args were passed, total will be not zero, and it will have a space at the end, so remove that */
if (total > 0)
diff --git a/cli-session.c b/cli-session.c
index 8bf530c..843c944 100644
--- a/cli-session.c
+++ b/cli-session.c
@@ -124,6 +124,8 @@ void cli_session(int sock_in, int sock_out, struct dropbear_progress_connection
/* Exchange identification */
send_session_identification();
+ kexfirstinitialise(); /* initialise the kex state */
+
send_msg_kexinit();
session_loop(cli_sessionloop);
diff --git a/common-algo.c b/common-algo.c
index 76d3977..8970523 100644
--- a/common-algo.c
+++ b/common-algo.c
@@ -144,12 +144,15 @@ algo_type sshciphers[] = {
#ifdef DROPBEAR_AES256
{"aes256-ctr", 0, &dropbear_aes256, 1, &dropbear_mode_ctr},
#endif
+#ifdef DROPBEAR_TWOFISH_CTR
+/* twofish ctr is conditional as it hasn't been tested for interoperability, see options.h */
#ifdef DROPBEAR_TWOFISH256
{"twofish256-ctr", 0, &dropbear_twofish256, 1, &dropbear_mode_ctr},
#endif
#ifdef DROPBEAR_TWOFISH128
{"twofish128-ctr", 0, &dropbear_twofish128, 1, &dropbear_mode_ctr},
#endif
+#endif /* DROPBEAR_TWOFISH_CTR */
#endif /* DROPBEAR_ENABLE_CTR_MODE */
#ifdef DROPBEAR_ENABLE_CBC_MODE
diff --git a/common-session.c b/common-session.c
index e565570..b712f05 100644
--- a/common-session.c
+++ b/common-session.c
@@ -90,8 +90,6 @@ void common_session_init(int sock_in, int sock_out) {
ses.maxfd = MAX(ses.maxfd, ses.signal_pipe[0]);
ses.maxfd = MAX(ses.maxfd, ses.signal_pipe[1]);
- kexfirstinitialise(); /* initialise the kex state */
-
ses.writepayload = buf_new(TRANS_MAX_PAYLOAD_LEN);
ses.transseq = 0;
diff --git a/netio.c b/netio.c
index af34a14..74eea7b 100644
--- a/netio.c
+++ b/netio.c
@@ -70,7 +70,7 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
struct addrinfo *r;
int res = 0;
int fastopen = 0;
-#ifdef DROPBEAR_TCP_FAST_OPEN
+#ifdef DROPBEAR_CLIENT_TCP_FAST_OPEN
struct msghdr message;
#endif
@@ -91,14 +91,13 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
set_piggyback_ack(c->sock);
#endif
-#ifdef DROPBEAR_TCP_FAST_OPEN
+#ifdef DROPBEAR_CLIENT_TCP_FAST_OPEN
fastopen = (c->writequeue != NULL);
- memset(&message, 0x0, sizeof(message));
- message.msg_name = r->ai_addr;
- message.msg_namelen = r->ai_addrlen;
-
- if (c->writequeue) {
+ if (fastopen) {
+ memset(&message, 0x0, sizeof(message));
+ message.msg_name = r->ai_addr;
+ message.msg_namelen = r->ai_addrlen;
/* 6 is arbitrary, enough to hold initial packets */
unsigned int iovlen = 6; /* Linux msg_iovlen is a size_t */
struct iovec iov[6];
@@ -106,18 +105,22 @@ static void connect_try_next(struct dropbear_progress_connection *c) {
message.msg_iov = iov;
message.msg_iovlen = iovlen;
res = sendmsg(c->sock, &message, MSG_FASTOPEN);
- if (res < 0 && errno != EINPROGRESS) {
- m_free(c->errstring);
- c->errstring = m_strdup(strerror(errno));
- /* Not entirely sure which kind of errors are normal - 2.6.32 seems to
- return EPIPE for any (nonblocking?) sendmsg(). just fall back */
- TRACE(("sendmsg tcp_fastopen failed, falling back. %s", strerror(errno)));
- /* No kernel MSG_FASTOPEN support. Fall back below */
- fastopen = 0;
- /* Set to NULL to avoid trying again */
- c->writequeue = NULL;
+ /* Returns EINPROGRESS if FASTOPEN wasn't available */
+ if (res < 0) {
+ if (errno != EINPROGRESS) {
+ m_free(c->errstring);
+ c->errstring = m_strdup(strerror(errno));
+ /* Not entirely sure which kind of errors are normal - 2.6.32 seems to
+ return EPIPE for any (nonblocking?) sendmsg(). just fall back */
+ TRACE(("sendmsg tcp_fastopen failed, falling back. %s", strerror(errno)));
+ /* No kernel MSG_FASTOPEN support. Fall back below */
+ fastopen = 0;
+ /* Set to NULL to avoid trying again */
+ c->writequeue = NULL;
+ }
+ } else {
+ packet_queue_consume(c->writequeue, res);
}
- packet_queue_consume(c->writequeue, res);
}
#endif
@@ -310,7 +313,7 @@ void set_sock_nodelay(int sock) {
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*)&val, sizeof(val));
}
-#ifdef DROPBEAR_TCP_FAST_OPEN
+#ifdef DROPBEAR_SERVER_TCP_FAST_OPEN
void set_listen_fast_open(int sock) {
int qlen = MAX(MAX_UNAUTH_PER_IP, 5);
if (setsockopt(sock, SOL_TCP, TCP_FASTOPEN, &qlen, sizeof(qlen)) != 0) {
diff --git a/netio.h b/netio.h
index 5d9f799..b413bdc 100644
--- a/netio.h
+++ b/netio.h
@@ -48,7 +48,7 @@ void connect_set_writequeue(struct dropbear_progress_connection *c, struct Queue
void packet_queue_to_iovec(struct Queue *queue, struct iovec *iov, unsigned int *iov_count);
void packet_queue_consume(struct Queue *queue, ssize_t written);
-#ifdef DROPBEAR_TCP_FAST_OPEN
+#ifdef DROPBEAR_SERVER_TCP_FAST_OPEN
/* Try for any Linux builds, will fall back if the kernel doesn't support it */
void set_listen_fast_open(int sock);
/* Define values which may be supported by the kernel even if the libc is too old */
diff --git a/options.h b/options.h
index e2d69a9..41cc129 100644
--- a/options.h
+++ b/options.h
@@ -103,10 +103,15 @@ much traffic. */
#define DROPBEAR_ENABLE_CBC_MODE
/* Enable "Counter Mode" for ciphers. This is more secure than normal
- * CBC mode against certain attacks. This adds around 1kB to binary
- * size and is recommended for most cases */
+ * CBC mode against certain attacks. It is recommended for security
+ * and forwards compatibility */
#define DROPBEAR_ENABLE_CTR_MODE
+/* Twofish counter mode is disabled by default because it
+has not been tested for interoperability with other SSH implementations.
+If you test it please contact the Dropbear author */
+/* #define DROPBEAR_TWOFISH_CTR */
+
/* You can compile with no encryption if you want. In some circumstances
* this could be safe security-wise, though make sure you know what
* you're doing. Anyone can see everything that goes over the wire, so
diff --git a/svr-authpasswd.c b/svr-authpasswd.c
index 7a5a121..0153a53 100644
--- a/svr-authpasswd.c
+++ b/svr-authpasswd.c
@@ -33,6 +33,8 @@
#ifdef ENABLE_SVR_PASSWORD_AUTH
+/* not constant time when strings are differing lengths.
+ string content isn't leaked, and crypt hashes are predictable length. */
static int constant_time_strcmp(const char* a, const char* b) {
size_t la = strlen(a);
size_t lb = strlen(b);
diff --git a/svr-main.c b/svr-main.c
index 5234086..cc59332 100644
--- a/svr-main.c
+++ b/svr-main.c
@@ -429,7 +429,7 @@ static size_t listensockets(int *socks, size_t sockcount, int *maxfd) {
for (n = 0; n < (unsigned int)nsock; n++) {
int sock = socks[sockpos + n];
set_sock_priority(sock, DROPBEAR_PRIO_LOWDELAY);
-#ifdef DROPBEAR_TCP_FAST_OPEN
+#ifdef DROPBEAR_SERVER_TCP_FAST_OPEN
set_listen_fast_open(sock);
#endif
}
diff --git a/svr-session.c b/svr-session.c
index 8485905..d638d59 100644
--- a/svr-session.c
+++ b/svr-session.c
@@ -138,6 +138,8 @@ void svr_session(int sock, int childpipe) {
/* exchange identification, version etc */
send_session_identification();
+
+ kexfirstinitialise(); /* initialise the kex state */
/* start off with key exchange */
send_msg_kexinit();
diff --git a/sysoptions.h b/sysoptions.h
index 11dc10d..185c8e6 100644
--- a/sysoptions.h
+++ b/sysoptions.h
@@ -262,9 +262,12 @@
/* Use this string since some implementations might special-case it */
#define DROPBEAR_KEEPALIVE_STRING "keepalive@openssh.com"
-/* Linux will attempt TCP fast open, falling back if not supported by the kernel */
+/* Linux will attempt TCP fast open, falling back if not supported by the kernel.
+ * Currently server is enabled but client is disabled by default until there
+ * is further compatibility testing */
#ifdef __linux__
-#define DROPBEAR_TCP_FAST_OPEN 1
+#define DROPBEAR_SERVER_TCP_FAST_OPEN
+/* #define DROPBEAR_CLIENT_TCP_FAST_OPEN */
#endif
/* no include guard for this file */