diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2015-12-29 13:38:01 +0000 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-12-29 13:38:01 +0000 |
commit | 700f0aff24d9b292f24d802c3af3b5c1705193c5 (patch) | |
tree | 0fd65ea4222b253dfe50c2a315c04212a985ce36 | |
parent | a3776489e653ab8796d808e507ee03ea651a8007 (diff) | |
parent | 02fdc2db225b1ca21aab2000ba4a873f335d6707 (diff) | |
download | libgit2-700f0aff24d9b292f24d802c3af3b5c1705193c5.tar.gz |
Merge pull request #3562 from mgorny/ssh-read-stderr-fail
ssh_stream_read(): fix possible *bytes_read < 0 branch
-rw-r--r-- | src/transports/ssh.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/transports/ssh.c b/src/transports/ssh.c index ffa4a24a7..239e0bae7 100644 --- a/src/transports/ssh.c +++ b/src/transports/ssh.c @@ -136,9 +136,14 @@ static int ssh_stream_read( * not-found error, so read from stderr and signal EOF on * stderr. */ - if (rc == 0 && (rc = libssh2_channel_read_stderr(s->channel, buffer, buf_size)) > 0) { - giterr_set(GITERR_SSH, "%*s", rc, buffer); - return GIT_EEOF; + if (rc == 0) { + if ((rc = libssh2_channel_read_stderr(s->channel, buffer, buf_size)) > 0) { + giterr_set(GITERR_SSH, "%*s", rc, buffer); + return GIT_EEOF; + } else if (rc < LIBSSH2_ERROR_NONE) { + ssh_error(s->session, "SSH could not read stderr"); + return -1; + } } |