From 89be6d0309f3ab7a869805b4de6ce63d769484c9 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 19 Jun 2013 12:32:10 +0200 Subject: [PATCH] examples: Check return value of fileno(). --- examples/libssh_scp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;