aboutsummaryrefslogtreecommitdiff
path: root/examples/sshnetcat.c
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-02-05 11:20:24 +0100
committerAndreas Schneider <asn@cryptomilk.org>2011-02-05 15:23:19 +0100
commit9e40e60bc425670b7d8a16d9c4fea9ee0230f275 (patch)
tree7706d6f960aa48722a1aac0f1303d1f3da72c25c /examples/sshnetcat.c
parent8f850585ddff035b8f680bb8fec56e14c2f2f96f (diff)
downloadlibssh-9e40e60bc425670b7d8a16d9c4fea9ee0230f275.tar.gz
libssh-9e40e60bc425670b7d8a16d9c4fea9ee0230f275.tar.xz
libssh-9e40e60bc425670b7d8a16d9c4fea9ee0230f275.zip
examples: Check return values of write.
Diffstat (limited to 'examples/sshnetcat.c')
-rw-r--r--examples/sshnetcat.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/examples/sshnetcat.c b/examples/sshnetcat.c
index 21b92425..cad777bb 100644
--- a/examples/sshnetcat.c
+++ b/examples/sshnetcat.c
@@ -125,8 +125,14 @@ static void select_loop(ssh_session session,ssh_channel channel){
channel_free(channel);
channel=channels[0]=NULL;
- } else
- write(1,buffer,lus);
+ } else {
+ ret = write(1, buffer, lus);
+ if (ret < 0) {
+ fprintf(stderr, "Error writing to stdin: %s",
+ strerror(errno));
+ return;
+ }
+ }
}
while(channel && channel_is_open(channel) && channel_poll(channel,1)){ /* stderr */
lus=channel_read(channel,buffer,sizeof(buffer),1);
@@ -141,7 +147,12 @@ static void select_loop(ssh_session session,ssh_channel channel){
channel_free(channel);
channel=channels[0]=NULL;
} else
- write(2,buffer,lus);
+ ret = write(2, buffer, lus);
+ if (ret < 0) {
+ fprintf(stderr, "Error writing to stderr: %s",
+ strerror(errno));
+ return;
+ }
}
}
if(channel && channel_is_closed(channel)){