Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 700f0af

Browse files
committed
Merge pull request libgit2#3562 from mgorny/ssh-read-stderr-fail
ssh_stream_read(): fix possible *bytes_read < 0 branch
2 parents a377648 + 02fdc2d commit 700f0af

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/transports/ssh.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,14 @@ static int ssh_stream_read(
136136
* not-found error, so read from stderr and signal EOF on
137137
* stderr.
138138
*/
139-
if (rc == 0 && (rc = libssh2_channel_read_stderr(s->channel, buffer, buf_size)) > 0) {
140-
giterr_set(GITERR_SSH, "%*s", rc, buffer);
141-
return GIT_EEOF;
139+
if (rc == 0) {
140+
if ((rc = libssh2_channel_read_stderr(s->channel, buffer, buf_size)) > 0) {
141+
giterr_set(GITERR_SSH, "%*s", rc, buffer);
142+
return GIT_EEOF;
143+
} else if (rc < LIBSSH2_ERROR_NONE) {
144+
ssh_error(s->session, "SSH could not read stderr");
145+
return -1;
146+
}
142147
}
143148

144149

0 commit comments

Comments
 (0)