fetch: Fix infinite loop on display progress
authorJohn Marino <draco@marino.st>
Thu, 1 Nov 2012 21:21:52 +0000 (22:21 +0100)
committerJohn Marino <draco@marino.st>
Thu, 1 Nov 2012 21:56:19 +0000 (22:56 +0100)
commit3eca42272f995aeaee9d72266e8812fa6860c9da
tree78840b3cff1d528e3e878b8d8b07875124509e77
parent884e58fc32b28a5820e1f1909368c4707aa58271
fetch: Fix infinite loop on display progress

As reported by FreeBSD PR bin/153240, fetch can loop forever if it is
interrupted by a signal at just the right time.

Verbatim from FreeBSD SVN 230307 (18 JAN 2012):
Fix two issues related to the use of SIGINFO in fetch(1) to display
progress information.  The first is that fetch_read() (used in the HTTP
code but not the FTP code) can enter an infinite loop if it has previously
been interrupted by a signal.  The second is that when it is interrupted,
fetch_read() will discard any data it may have read up to that point.
Luckily, both bugs are extremely timing-sensitive and therefore difficult

to trigger.
lib/libfetch/common.c
lib/libfetch/common.h
lib/libfetch/http.c
usr.bin/fetch/fetch.c