aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2013-06-19 12:32:10 +0200
committerAndreas Schneider <asn@cryptomilk.org>2013-06-19 12:32:10 +0200
commit89be6d0309f3ab7a869805b4de6ce63d769484c9 (patch)
treeb759099d9254c3a279860d39a8364f9f1efb4d96 /examples
parent36e4c2e5bcbdfcfcdf4c7b1df9b6b51be05b7b56 (diff)
downloadlibssh-89be6d0309f3ab7a869805b4de6ce63d769484c9.tar.gz
libssh-89be6d0309f3ab7a869805b4de6ce63d769484c9.tar.xz
libssh-89be6d0309f3ab7a869805b4de6ce63d769484c9.zip
examples: Check return value of fileno().
Diffstat (limited to 'examples')
-rw-r--r--examples/libssh_scp.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/examples/libssh_scp.c b/examples/libssh_scp.c
index 7dee81ba..b7471da6 100644
--- a/examples/libssh_scp.c
+++ b/examples/libssh_scp.c
@@ -179,7 +179,11 @@ static int do_copy(struct location *src, struct location *dest, int recursive){
(void)recursive;
/* Get the file name and size*/
if(!src->is_ssh){
- fd=fileno(src->file);
+ fd = fileno(src->file);
+ if (fd < 0) {
+ fprintf(stderr, "Invalid file pointer, error: %s\n", strerror(errno));
+ return -1;
+ }
fstat(fd,&s);
size=s.st_size;
mode = s.st_mode & ~S_IFMT;