summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2010-06-29 10:42:36 +0200
committerAndreas Schneider <asn@samba.org>2010-06-29 11:12:12 +0200
commitee01fe8c5bd450c82db3f7a7e8c783ac32b0812d (patch)
tree3f26089c1300a35181b07f504f169750c9316d2a /source3/client
parentf324036e76abb0b572fb65c4c403e7ede259682a (diff)
downloadsamba-ee01fe8c5bd450c82db3f7a7e8c783ac32b0812d.tar.gz
samba-ee01fe8c5bd450c82db3f7a7e8c783ac32b0812d.tar.bz2
samba-ee01fe8c5bd450c82db3f7a7e8c783ac32b0812d.zip
s3-client: Make sure we only write to an opened file.
Found by clang-analyzer.
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/clitar.c14
1 files changed, 10 insertions, 4 deletions
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 */