Don't ignore transport errors when writing to channel (#804150)

This commit is contained in:
Kamil Dudka 2012-03-19 14:58:27 +01:00
parent 1d6da849c3
commit 8e8214ab77
4 changed files with 44 additions and 3 deletions

View File

@ -1,6 +1,6 @@
--- libssh2/NEWS
+++ libssh2/NEWS
@@ -2507,7 +2507,7 @@
@@ -2886,7 +2886,7 @@
- support arcfour128 cipher per RFC 4345
Daniel Stenberg (21 Oct 2009)

View File

@ -26,7 +26,7 @@ index 40818c0..481982c 100644
#include <openssl/aes.h>
#include <openssl/evp.h>
@@ -362,6 +362,8 @@ void _libssh2_init_aes_ctr(void)
@@ -358,6 +358,8 @@ void _libssh2_init_aes_ctr(void)
_libssh2_EVP_aes_256_ctr();
}

View File

@ -0,0 +1,34 @@
From fed075972080ed705bd79b731c40cf5e73085aeb Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Thu, 15 Mar 2012 13:03:08 +0100
Subject: [PATCH] channel_write: acknowledge transport errors
When draining data off the socket with _libssh2_transport_read() (which
in turn has to be done so that we can be sure to have read any possible
window-increasing packets), this code previously ignored errors which
could lead to nasty loops. Now all error codes except EAGAIN will cause
the error to be returned at once.
Bug: http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0068.shtml
Reported by: Matthew Booth
---
src/channel.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/channel.c b/src/channel.c
index 8d6fb0a..9e29492 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -2008,6 +2008,9 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
rc = _libssh2_transport_read(session);
while (rc > 0);
+ if((rc < 0) && (rc != LIBSSH2_ERROR_EAGAIN))
+ return rc;
+
if(channel->local.window_size <= 0)
/* there's no room for data so we stop */
return (rc==LIBSSH2_ERROR_EAGAIN?rc:0);
--
1.7.1

View File

@ -9,7 +9,7 @@
Name: libssh2
Version: 1.4.0
Release: 3%{?dist}
Release: 4%{?dist}
Summary: A library implementing the SSH2 protocol
Group: System Environment/Libraries
License: BSD
@ -19,6 +19,7 @@ Patch0: libssh2-1.2.9-utf8.patch
Patch1: libssh2-1.4.0-c4a0e0.patch
Patch2: libssh2-1.4.0-cc4f9d.patch
Patch3: libssh2-1.4.0-f4f229.patch
Patch4: libssh2-1.4.0-fed075.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -nu)
BuildRequires: openssl-devel
BuildRequires: zlib-devel
@ -78,6 +79,9 @@ developing applications that use libssh2.
# Don't try to use openssl's AES-CTR functions (upstream patch)
%patch3 -p1
# Don't ignore transport errors in channel_write (upstream patch, #804150)
%patch4 -p1
# Make sshd transition appropriately if building in an SELinux environment
chcon $(/usr/sbin/matchpathcon -n /etc/rc.d/init.d/sshd) tests/ssh2.sh || :
chcon -R $(/usr/sbin/matchpathcon -n /etc) tests/etc || :
@ -139,6 +143,9 @@ rm -rf %{buildroot}
%{_libdir}/pkgconfig/libssh2.pc
%changelog
* Mon Mar 19 2012 Kamil Dudka <kdudka@redhat.com> 1.4.0-4
- Don't ignore transport errors when writing to channel (#804150)
* Sun Mar 18 2012 Paul Howarth <paul@city-fan.org> 1.4.0-3
- Don't try to use openssl's AES-CTR functions
(http://www.libssh2.org/mail/libssh2-devel-archive-2012-03/0111.shtml)