Package: zsync
Version: 0.6.1-1
Severity: important
Tags: patch lfs
User: [email protected]
Usertags: origin-ubuntu lucid ubuntu-patch
Hi Robert,
In Ubuntu, we've applied the attached patch to add large file support to
zsync, which enables users on 32-bit architectures to use zsync for, e.g.,
DVDs (or any other files > 2GB in size). I would suggest applying it to
the Debian package as well, particularly given that LFS support is a
longstanding goal in Debian.
The corresponding changelog entry for this patch is:
* debian/rules: build with $(shell getconf LFS_CFLAGS), so that we can
handle files over 2GB (such as DVD images) on 32-bit systems.
* http.c:
- use off_t instead of size_t where appropriate, for 64-bit cleanness
* libzsync/zsync.c:
- Use atoll() instead of atol(), to ensure support for > 32bit file
sizes.
- Cast to off_t before multiplying, otherwise we get random overflowage
on the byte range.
Cheers,
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
[email protected] [email protected]
diff -u zsync-0.6.1/debian/rules zsync-0.6.1/debian/rules
--- zsync-0.6.1/debian/rules
+++ zsync-0.6.1/debian/rules
@@ -3,7 +3,7 @@
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
-CFLAGS = -Wall -g
+CFLAGS = -Wall -g $(shell getconf LFS_CFLAGS)
ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
CFLAGS += -O0
only in patch2:
unchanged:
--- zsync-0.6.1.orig/http.c
+++ zsync-0.6.1/http.c
@@ -440,9 +440,9 @@
}
{ /* Now the actual content. Show progress as we go. */
- size_t got = 0;
+ off_t got = 0;
struct progress p = { 0, 0, 0, 0 };
- size_t r;
+ off_t r;
if (!no_progress)
do_progress(&p, 0, got);
@@ -514,7 +516,7 @@
* response, this is the boundary string. */
/* State for block currently being read */
- size_t block_left; /* non-zero if we're in the middle of reading a block */
+ off_t block_left; /* non-zero if we're in the middle of reading a block */
off_t offset; /* and this is the offset of the start of the block we are reading */
/* Buffering of data from the remote server */
@@ -1116,10 +1116,10 @@
* space left in the caller's buffer
* the amount we have actually read from the remote
*/
- size_t rl = rf->block_left;
+ off_t rl = rf->block_left;
if (rl > dlen)
rl = dlen;
- if ((size_t) (rf->buf_end - rf->buf_start) < rl) {
+ if ((off_t) (rf->buf_end - rf->buf_start) < rl) {
rl = rf->buf_end - rf->buf_start;
/* There is more data in this block, and space for more in the
only in patch2:
unchanged:
--- zsync-0.6.1.orig/libzsync/zsync.c
+++ zsync-0.6.1/libzsync/zsync.c
@@ -194,7 +194,7 @@
}
}
else if (!strcmp(buf, "Length")) {
- zs->filelen = atol(p);
+ zs->filelen = atoll(p);
}
else if (!strcmp(buf, "Filename")) {
zs->filename = strdup(p);
@@ -423,10 +423,10 @@
if (got) {
int todo = zs->blocks - rcksum_blocks_todo(zs->rs);
- *got = todo * zs->blocksize;
+ *got = (off_t)todo * zs->blocksize;
}
if (total)
- *total = zs->blocks * zs->blocksize;
+ *total = (off_t)zs->blocks * zs->blocksize;
}
/* zsync_get_urls(self, &num, &type)
@@ -474,8 +474,8 @@
/* Now convert blocks to bytes */
for (i = 0; i < nrange; i++) {
- byterange[2 * i] = blrange[2 * i] * zs->blocksize;
- byterange[2 * i + 1] = blrange[2 * i + 1] * zs->blocksize - 1;
+ byterange[2 * i] = (off_t)blrange[2 * i] * zs->blocksize;
+ byterange[2 * i + 1] = (off_t)blrange[2 * i + 1] * zs->blocksize - 1;
}
free(blrange); /* And release the blocks, we're done with them */