1

Fix debug panic on download with redirect body. by ehuss · Pull Request #10048 ·...

 2 years ago
source link: https://github.com/rust-lang/cargo/pull/10048
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Copy link

Contributor

ehuss commented 13 days ago

With a debug build of cargo, downloading crates can panic if the download host issues a redirect with a body. From what I can see, the curl progress function gets called with the original size of the redirect body (such as total=154 cur=154, indicating that it has read 154 bytes of the redirect message). Then it calls the progress function again with cur=0 to start again from the beginning. The next line in this patch, cur - dl.current.get() would panic since it is a u64 and a 0 value of cur is less than the old current.

This was never really an issue with crates.io because it emits a redirect body of 0 bytes.

I think it is fine to skip this block in that situation, as it is only for resetting the timeout counter. Though, I guess it could use saturating_sub instead.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK