bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] printf: more error handling


From: Grisha Levit
Subject: Re: [PATCH] printf: more error handling
Date: Fri, 2 Feb 2024 18:33:02 -0500

On Thu, Feb 1, 2024 at 7:41 PM Chet Ramey <chet.ramey@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:

   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? 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?

[1]: 
https://git.savannah.gnu.org/cgit/bash.git/diff/builtins/printf.def?h=devel&id=35465406&dt=1#n178



reply via email to

[Prev in Thread] Current Thread [Next in Thread]