diff options
author | Christian Ambach <ambi@samba.org> | 2016-02-08 23:27:09 +0100 |
---|---|---|
committer | Christian Ambach <ambi@samba.org> | 2016-02-26 11:31:32 +0100 |
commit | 113f8dd3d9e0d04b03b61f415b3c410ba75260f5 (patch) | |
tree | 4ab7e01883a6fe860b2431bcf78764411c29173b /source3/utils/smbget.c | |
parent | 01ba35dca2f721fa5b3c31da7fa991e7d1479cc7 (diff) | |
download | samba-113f8dd3d9e0d04b03b61f415b3c410ba75260f5.tar.gz |
s3:utils/smbget improve check of write() result
check that all bytes in the buffer have been written
Signed-off-by: Christian Ambach <ambi@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Diffstat (limited to 'source3/utils/smbget.c')
-rw-r--r-- | source3/utils/smbget.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c index 79574177cf0..998761f8482 100644 --- a/source3/utils/smbget.c +++ b/source3/utils/smbget.c @@ -600,9 +600,10 @@ static bool smb_download_file(const char *base, const char *name, /* Now, download all bytes from offset_download to the end */ for (curpos = offset_download; curpos < remotestat.st_size; curpos += opt.blocksize) { - ssize_t bytesread = smbc_read(remotehandle, - readbuf, - opt.blocksize); + ssize_t bytesread; + ssize_t byteswritten; + + bytesread = smbc_read(remotehandle, readbuf, opt.blocksize); if(bytesread < 0) { fprintf(stderr, "Can't read %zu bytes at offset %jd, file %s\n", @@ -617,7 +618,8 @@ static bool smb_download_file(const char *base, const char *name, total_bytes += bytesread; - if(write(localhandle, readbuf, bytesread) < 0) { + byteswritten = write(localhandle, readbuf, bytesread); + if (byteswritten != bytesread) { fprintf(stderr, "Can't write %zd bytes to local file %s at " "offset %jd\n", bytesread, path, |