aboutsummaryrefslogtreecommitdiff
path: root/examples/libssh_scp.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/libssh_scp.c')
-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;