Comment 4 for bug 420931

Revision history for this message
Steve Beattie (sbeattie) wrote : Re: zsync crashed with SIGSEGV

The last zsync merge did the following:

@@ -1000,23 +1006,11 @@

             /* Otherwise, we're reading the MIME headers for this part until we get \r\n alone */
             for (; buf[0] != '\r' && buf[0] != '\n' && buf[0] != '\0';) {
- off_t from, to;
-
- /* Get next header */
- if (!rfgets(buf, sizeof(buf), rf))
- return 0;
- buflwr(buf); /* HTTP headers are case insensitive */
-
- /* We're looking for the Content-Range: header, to tell us how
- * many bytes and what part of the target file they represent.
- */
- if (2 ==
- sscanf(buf,
- "content-range: bytes " OFF_T_PF "-" OFF_T_PF "/",
- &from, &to)) {
- rf->offset = from;
- rf->block_left = to - from + 1;
- gotr = 1;
+ int from, to;
+ if (!rfgets(buf,sizeof(buf),rf)) return 0;
+ buflwr(buf);
+ if (2 == sscanf(buf,"content-range: bytes %d-%d/",&from,&to)) {
+ rf->offset = from - global_offset; rf->block_left = to - from + 1; gotr = 1;
                 }
             }

which changes from and to from off_t to ints; unfortunately, the dvds that I'm attempting download via zsync are larger than 2GB, so from and to suffer from signed int overflows in this case. I've reverted the code in this section mostly back to the way upstream had it, keeping the 'rf->offset = from - global_offset;' bit, since that's what the actual intended ubuntu difference (to support the undocumented -O global offset argument, apparently) consists of. I've pushed this fix to lp:~sbeattie/ubuntu/karmic/zsync/zsync-fixups and built a package for testing in my ppa at https://launchpad.net/~sbeattie/+archive/ppa/. I've been using this package for a few hours and I'm able to download a daily ubuntu dvd that with the 0.6-1ubuntu1 version consistently SEGV's.