Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160915162554.GJ15995@brightrain.aerifal.cx>
Date: Thu, 15 Sep 2016 12:25:54 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] fix printf regression with alt-form octal,
 default precision

On Thu, Sep 15, 2016 at 12:22:57PM -0400, Rich Felker wrote:
> On Thu, Sep 15, 2016 at 07:04:34PM +0300, Dmitry V. Levin wrote:
> > Ping?
> > 
> > On Thu, Aug 04, 2016 at 04:07:40AM +0300, Dmitry V. Levin wrote:
> > > commit v1.1.5-10-gb91cdbe2bc8b626aa04dc6e3e84345accf34e4b1 that fixed
> > > behavior of printf with alt-form octal, zero precision, zero value,
> > > at the same time broke alt-form octal with default precision,
> > > e. g. printf("%#09o", 1).
> > > ---
> > >  src/stdio/vfprintf.c | 9 ++++++++-
> > >  1 file changed, 8 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
> > > index 2ecf769..ac2891c 100644
> > > --- a/src/stdio/vfprintf.c
> > > +++ b/src/stdio/vfprintf.c
> > > @@ -570,7 +570,14 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
> > >  			if (0) {
> > >  		case 'o':
> > >  			a = fmt_o(arg.i, z);
> > > -			if ((fl&ALT_FORM) && p<z-a+1) p=z-a+1;
> > > +			if (fl&ALT_FORM) {
> > > +				if (p >= 0 && p<z-a+1) {
> > > +					p=z-a+1;
> > > +				} else if (arg.i) {
> > > +					prefix+=5;
> > > +					pl=1;
> > > +				}
> > > +			}
> 
> This still does not fix all cases, e.g. printf("%#09.0o\n", 0);

Oh, never mind, '0' flag is specified to be ignored if a precision is
specified; this isn't a bug. I'll check and see if anything else is
wrong.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.