summaryrefslogtreecommitdiff
path: root/source3/utils
diff options
context:
space:
mode:
authorChristian Ambach <ambi@samba.org>2016-02-08 23:27:09 +0100
committerChristian Ambach <ambi@samba.org>2016-02-26 11:31:32 +0100
commit113f8dd3d9e0d04b03b61f415b3c410ba75260f5 (patch)
tree4ab7e01883a6fe860b2431bcf78764411c29173b /source3/utils
parent01ba35dca2f721fa5b3c31da7fa991e7d1479cc7 (diff)
downloadsamba-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')
-rw-r--r--source3/utils/smbget.c10
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,