Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Feb 2016 19:15:48 -0500
From:      Pedro Giffuni <pfg@FreeBSD.org>
To:        cem@FreeBSD.org
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r295631 - head/lib/libc/stdio
Message-ID:  <56C26A34.1000300@FreeBSD.org>
In-Reply-To: <CAG6CVpWN8Me9bZd-=b%2B_jVW_Wjgnq2X%2BLA-SHvYQezJ6YjxR3g@mail.gmail.com>
References:  <201602151813.u1FIDXAt067326@repo.freebsd.org> <CAG6CVpWN8Me9bZd-=b%2B_jVW_Wjgnq2X%2BLA-SHvYQezJ6YjxR3g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help


On 02/15/16 13:32, Conrad Meyer wrote:
> On Mon, Feb 15, 2016 at 10:13 AM, Pedro F. Giffuni <pfg@freebsd.org> wrote:
>> Author: pfg
>> Date: Mon Feb 15 18:13:33 2016
>> New Revision: 295631
>> URL: https://svnweb.freebsd.org/changeset/base/295631
>> ...
>>    Note that this implementation convention cannot be adhered to for strings
>>    longer than {INT_MAX} bytes as the value would not be representable in the
>>    return type of the function. For backwards-compatibility, implementations
>>    can return the number of bytes for strings of up to {INT_MAX} bytes, and
>>    return {INT_MAX} for all longer strings.
>> ...
>> --- head/lib/libc/stdio/fputs.c Mon Feb 15 17:14:10 2016        (r295630)
>> +++ head/lib/libc/stdio/fputs.c Mon Feb 15 18:13:33 2016        (r295631)
>> ...
>> @@ -62,5 +63,7 @@ fputs(const char * __restrict s, FILE *
>>          ORIENT(fp, -1);
>>          retval = __sfvwrite(fp, &uio);
>>          FUNLOCKFILE(fp);
>> +       if (retval == 0)
>> +               return (iov.iov_len > INT_MAX ? INT_MAX : uio.uio_resid);
>
>                   ^^^^^^^^^^^ why not uio.uio_resid here as well?
>

Because uio.ui_resid is an int and it's likely to overflow before it 
keeps a useful value for that comparison, Of course, as Bruce noted,
__sfwrite modifies uio so uio.uio_resid doesn't belong there at all.

Hmm... we need some fputs() tests in the testsuite.

Pedro.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56C26A34.1000300>