From 351e4107ed381aa699af1abe499d9b0994a7ab10 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sun, 14 Jul 2013 15:01:06 +0200 Subject: examples: Check return value of fstat(). CID #743297 --- examples/libssh_scp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'examples/libssh_scp.c') diff --git a/examples/libssh_scp.c b/examples/libssh_scp.c index 9027ef9..99281db 100644 --- a/examples/libssh_scp.c +++ b/examples/libssh_scp.c @@ -192,7 +192,10 @@ static int do_copy(struct location *src, struct location *dest, int recursive){ fprintf(stderr, "Invalid file pointer, error: %s\n", strerror(errno)); return -1; } - fstat(fd,&s); + r = fstat(fd, &s); + if (r < 0) { + return -1; + } size=s.st_size; mode = s.st_mode & ~S_IFMT; filename=ssh_basename(src->path); -- cgit