On 2/2/24 6:33 PM, Grisha Levit wrote:
On Thu, Feb 1, 2024 at 7:41 PM Chet Ramey <chet.ra...@case.edu> wrote:

On 1/22/24 9:44 PM, Grisha Levit wrote:
The size of the buffer used for printf -v is tracked in an int but this
can overflow since the buffer can be built up by multiple vsnprintf(3)
calls, each of which can append up to INT_MAX bytes to the buffer:

Thanks for the report and patch.

Thanks, a small question -- in your commit[1] you added an ferror check here:

No, I just left it in.


    177       nw = vflag ? vbprintf (f, func) : printf (f, func); \
    178     if (nw < 0 || ferror (stdout)) \
    179       { \

Is it necessary to check the error indicator if printf(3) just had a non-
negative return?

I think printf is allowed to set the error flag that ferror checks even if
it returns 0, but I could be convinced otherwise.


And, if so, can this check be, as elsewhere:
`(vflag == 0 && ferror (stdout))'?  I think `printf -v' should work no
matter what the state of stdout is, no?

Sure.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

Reply via email to