apt-get update fails hash checks on https repositories when file size changes
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
apt (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned | ||
Precise |
Won't Fix
|
Undecided
|
Unassigned |
Bug Description
apt uses its own strategy for sending Range: requests on https, instead of the libcurl handling. Here's is a scenario where it gets it wrong:
1) apt downloads the file but doesn't put the file in place yet (perhaps it got interrupted or something)
2) the file on the server gets replaced by a smaller file
3) the next update run wants to download the file, sees a partial read, and asks for Range: (len(file)-1)-
4) the server sees a Range: request for a byte-range past the end of (the current version of) the file, considers it invalid, and streams the entire file. (This is correct behavior.)
5) apt assumes the response is the range it expected, and appends it to the local staging copy (minus one byte).
Instead of rolling apt's own attempt to handle ranges in the https method, it should just use libcurl's. Attached is a patch which solves the problem.
Oh, and the bug is particularly pathological. Because after it happens, the index file is in the staging area is now always larger than what's on the server, it won't self correct.