On Wed, Jan 18, 2012 at 03:13:22PM +0000, Dag-Erling Smorgrav wrote:
> Author: des
> Date: Wed Jan 18 15:13:21 2012
> New Revision: 230307
> URL: http://svn.freebsd.org/changeset/base/230307
> 
> Log:
>   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.
>   
>   PR:         bin/153240
>   Submitted by:       Mark <mark...@gmail.com>
>   MFC after:  3 weeks
[...]
> +static int
> +fetch_cache_data(conn_t *conn, char *src, size_t nbytes)
> +{
> +     char *tmp;
> +
> +     if (conn->cache.size < nbytes) {
> +             tmp = realloc(conn->cache.buf, nbytes);
> +             if (tmp == NULL) {
> +                     errno = ENOMEM;

realloc(3) on failures sets errno to ENOMEM for you already.

> +             conn->cache.len -= total;
> +             conn->cache.pos += total;
> +             len -= total;
> +             buf+= total;

Style nit (missing space before +=).

-- 
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://tupytaj.pl

Attachment: pgpYHPSr3wwP9.pgp
Description: PGP signature

Reply via email to