summaryrefslogtreecommitdiff
path: root/source3/client
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-03-26 22:34:25 +0000
committerJeremy Allison <jra@samba.org>2001-03-26 22:34:25 +0000
commit4e35283a8b2c4b816b7aec821c719378a1ef10a6 (patch)
tree04cb1a06aa58405ea4bc645cf7e408c9f253f6fa /source3/client
parent7adb11393e58cc2f93b4079be422160b29ea348d (diff)
downloadsamba-4e35283a8b2c4b816b7aec821c719378a1ef10a6.tar.gz
samba-4e35283a8b2c4b816b7aec821c719378a1ef10a6.tar.bz2
samba-4e35283a8b2c4b816b7aec821c719378a1ef10a6.zip
Fix for smbtar race condition from Glenn Burkhardt <glenn@aoi.ultranet.com>.
Jeremy. (This used to be commit 0c9a92a0557b2595e520cbaf2feaa587f9e7502d)
Diffstat (limited to 'source3/client')
-rw-r--r--source3/client/clitar.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index fe0fc83e4c..f6e0423025 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -729,6 +729,17 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
break;
}
+ nread += datalen;
+
+ /* if file size has increased since we made file size query, truncate
+ read so tar header for this file will be correct.
+ */
+
+ if (nread > finfo.size) {
+ datalen -= nread - finfo.size;
+ DEBUG(0,("File size change - truncating %s to %d bytes\n", finfo.name, (int)finfo.size));
+ }
+
/* add received bits of file to buffer - dotarbuf will
* write out in 512 byte intervals */
if (dotarbuf(tarhandle,data,datalen) != datalen) {
@@ -736,7 +747,6 @@ static void do_atar(char *rname,char *lname,file_info *finfo1)
break;
}
- nread += datalen;
if (datalen == 0) {
DEBUG(0,("Error reading file %s. Got 0 bytes\n", rname));
break;