summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-01-03 19:57:12 +0000
committerJeremy Allison <jra@samba.org>2002-01-03 19:57:12 +0000
commit791433434eeca62e989f35087a33156032b90dd6 (patch)
tree4522f1785e161bd87de8c2e16a7fee9d253c226c
parent9e0297b3edd01d5c9b7e99881f72421706b4f9e2 (diff)
downloadsamba-791433434eeca62e989f35087a33156032b90dd6.tar.gz
samba-791433434eeca62e989f35087a33156032b90dd6.tar.bz2
samba-791433434eeca62e989f35087a33156032b90dd6.zip
Fixed embarressing 16k strack trashing bug :-(.
Jeremy. (This used to be commit b52c3219d6f46df6e98742447d65ecda2ecbac65)
-rw-r--r--source3/lib/util.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 55bb3647fc..3f74070830 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -571,13 +571,14 @@ ssize_t transfer_file_internal(int infd, int outfd, size_t n, ssize_t (*read_fn)
static char buf[16384];
size_t total = 0;
ssize_t read_ret;
- size_t write_total = 0;
- ssize_t write_ret;
+ ssize_t write_ret;
+ size_t num_to_read_thistime;
+ size_t num_written = 0;
while (total < n) {
- size_t num_to_read_thistime = MIN((n - total), sizeof(buf));
+ num_to_read_thistime = MIN((n - total), sizeof(buf));
- read_ret = (*read_fn)(infd, buf + total, num_to_read_thistime);
+ read_ret = (*read_fn)(infd, buf, num_to_read_thistime);
if (read_ret == -1) {
DEBUG(0,("transfer_file_internal: read failure. Error = %s\n", strerror(errno) ));
return -1;
@@ -585,10 +586,10 @@ ssize_t transfer_file_internal(int infd, int outfd, size_t n, ssize_t (*read_fn)
if (read_ret == 0)
break;
- write_total = 0;
+ num_written = 0;
- while (write_total < read_ret) {
- write_ret = (*write_fn)(outfd,buf + total, read_ret);
+ while (num_written < read_ret) {
+ write_ret = (*write_fn)(outfd,buf + num_written, read_ret);
if (write_ret == -1) {
DEBUG(0,("transfer_file_internal: write failure. Error = %s\n", strerror(errno) ));
@@ -597,7 +598,7 @@ ssize_t transfer_file_internal(int infd, int outfd, size_t n, ssize_t (*read_fn)
if (write_ret == 0)
return (ssize_t)total;
- write_total += (size_t)write_ret;
+ num_written += (size_t)write_ret;
}
total += (size_t)read_ret;