Skip to content

Commit 4b8013a

Browse files
committed
example: treat the libssh2_channel_read() return code properly
A short read is not an error. Only negative values are errors!
1 parent 697b4e8 commit 4b8013a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Diff for: example/scp.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ int main(int argc, char *argv[])
151151
}
152152

153153
rc = libssh2_channel_read(channel, mem, amount);
154-
if(rc == amount) {
154+
if(rc > 0) {
155155
write(1, mem, rc);
156156
}
157-
else {
157+
else if(rc < 0) {
158158
fprintf(stderr, "libssh2_channel_read() failed: %d\n", rc);
159159
break;
160160
}

0 commit comments

Comments
 (0)