diff -u dropbear-2013.60/debian/changelog dropbear-2013.60/debian/changelog --- dropbear-2013.60/debian/changelog +++ dropbear-2013.60/debian/changelog @@ -1,3 +1,10 @@ +dropbear (2013.60-1ubuntu2.2) trusty; urgency=medium + + * Cat of long files breaks dropbear ssh connection (LP: #1497883) + Patch can be found in comment #10 + + -- Gerald Yang Tue, 02 May 2017 16:57:00 +0800 + dropbear (2013.60-1ubuntu2.1) trusty; urgency=medium * Enable hmac-sha2-256 and hmac-sha2-512 MAC algorithms (LP: #1409798) only in patch2: unchanged: --- dropbear-2013.60.orig/packet.c +++ dropbear-2013.60/packet.c @@ -60,14 +60,27 @@ struct iovec *iov = NULL; int i; struct Link *l; + int iov_max_count; #endif TRACE2(("enter write_packet")) dropbear_assert(!isempty(&ses.writequeue)); -#ifdef HAVE_WRITEV - iov = m_malloc(sizeof(*iov) * ses.writequeue.count); - for (l = ses.writequeue.head, i = 0; l; l = l->link, i++) +#if defined(HAVE_WRITEV) && (defined(IOV_MAX) || defined(UIO_MAXIOV)) + +#ifndef IOV_MAX +#define IOV_MAX UIO_MAXIOV +#endif + + /* Make sure the size of the iov is below the maximum allowed by the OS. */ + iov_max_count = ses.writequeue.count; + if (iov_max_count > IOV_MAX) + { + iov_max_count = IOV_MAX; + } + + iov = m_malloc(sizeof(*iov) * iov_max_count); + for (l = ses.writequeue.head, i = 0; i < iov_max_count; l = l->link, i++) { writebuf = (buffer*)l->item; packet_type = writebuf->data[writebuf->len-1]; @@ -79,7 +92,7 @@ iov[i].iov_base = buf_getptr(writebuf, len); iov[i].iov_len = len; } - written = writev(ses.sock_out, iov, ses.writequeue.count); + written = writev(ses.sock_out, iov, iov_max_count); if (written < 0) { if (errno == EINTR) { m_free(iov); @@ -109,8 +122,7 @@ } m_free(iov); - -#else +#else /* No writev () */ /* Get the next buffer in the queue of encrypted packets to write*/ writebuf = (buffer*)examine(&ses.writequeue); @@ -146,7 +158,7 @@ buf_incrpos(writebuf, written); } -#endif +#endif /* writev */ now = time(NULL); ses.last_trx_packet_time = now;