summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'net-ftp/pure-ftpd/files/pure-ftpd-1.0.22-fix_rest_with_throttling.patch')
-rw-r--r--net-ftp/pure-ftpd/files/pure-ftpd-1.0.22-fix_rest_with_throttling.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/net-ftp/pure-ftpd/files/pure-ftpd-1.0.22-fix_rest_with_throttling.patch b/net-ftp/pure-ftpd/files/pure-ftpd-1.0.22-fix_rest_with_throttling.patch
new file mode 100644
index 000000000000..d9b2a25ff5d8
--- /dev/null
+++ b/net-ftp/pure-ftpd/files/pure-ftpd-1.0.22-fix_rest_with_throttling.patch
@@ -0,0 +1,77 @@
+--- src/ftpd.c.orig 2009-10-22 16:58:51.000000000 +0200
++++ src/ftpd.c 2009-10-22 17:06:18.000000000 +0200
+@@ -3096,25 +3096,23 @@
+
+ int mmap_send(int f, struct stat st, double *started)
+ {
+- off_t s;
+ off_t skip;
+ off_t o;
+- char *p, *buf;
+- off_t left;
++ char *buf;
+ # ifdef THROTTLING
+ double ended;
+ off_t transmitted = 0;
+ # endif
+
+- o = restartat & ~(map_size - 1);
+- skip = restartat - o;
++ skip = restartat % page_size;
++ o = restartat - skip;
+ while (o < st.st_size) {
+ # ifdef FTPWHO
+ if (shm_data_cur != NULL) {
+ shm_data_cur->download_current_size = o;
+ }
+ # endif
+- left = st.st_size - o;
++ off_t left = st.st_size - o;
+ if (left > (off_t) dl_chunk_size) {
+ left = (off_t) dl_chunk_size;
+ }
+@@ -3125,19 +3123,19 @@
+ error(451, MSG_MMAP_FAILED);
+ return -1;
+ }
+- p = buf;
++
+ o += left;
+- s = left;
++ off_t s = left;
+ while (left > skip) {
+ ssize_t w;
+
+ # ifdef WITH_TLS
+ if (enforce_tls_auth && data_protection_level == CPL_PRIVATE) {
+- w = secure_safe_write (p + skip, (size_t) (left - skip));
++ w = secure_safe_write (buf + (s - left) + skip, (size_t) left - skip );
+ } else
+ # endif
+ {
+- while ((w = write(xferfd, p + skip, (size_t) (left - skip))) <
++ while ((w = write(xferfd, buf + (s - left) + skip, (size_t) left) - skip) <
+ (ssize_t) 0 && errno == EINTR);
+ }
+ if (w < (ssize_t) 0) {
+@@ -3180,9 +3178,9 @@
+ }
+ downloaded += (unsigned long long) w;
+ left -= w;
+- p += w;
++
+ # ifdef THROTTLING
+- if (throttling_bandwidth_dl > 0UL) {
++ if (throttling_bandwidth_dl > 0UL && o < st.st_size) {
+ long double delay;
+
+ ended = get_usec_time();
+@@ -3201,7 +3199,7 @@
+ }
+ # endif
+ }
+- skip = (off_t) 0;
++ skip = 0;
+ (void) munmap(buf, s);
+ }
+