From ee01fe8c5bd450c82db3f7a7e8c783ac32b0812d Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 29 Jun 2010 10:42:36 +0200 Subject: s3-client: Make sure we only write to an opened file. Found by clang-analyzer. --- source3/client/clitar.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'source3') diff --git a/source3/client/clitar.c b/source3/client/clitar.c index fc98fa8e33..0a1adb463e 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -998,16 +998,22 @@ static int skip_file(int skipsize) static int get_file(file_info2 finfo) { - uint16_t fnum; + uint16_t fnum = (uint16_t) -1; int pos = 0, dsize = 0, bpos = 0; uint64_t rsize = 0; + NTSTATUS status; DEBUG(5, ("get_file: file: %s, size %.0f\n", finfo.name, (double)finfo.size)); - if (ensurepath(finfo.name) && - (!NT_STATUS_IS_OK(cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE,&fnum)))) { + if (!ensurepath(finfo.name)) { DEBUG(0, ("abandoning restore\n")); - return(False); + return False; + } + + status = cli_open(cli, finfo.name, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("abandoning restore\n")); + return False; } /* read the blocks from the tar file and write to the remote file */ -- cgit