[Top][All Lists]

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

Re: bug#9129: Built-in printf Sits Awkwardly with UDP.

From: Ralph Corderoy
Subject: Re: bug#9129: Built-in printf Sits Awkwardly with UDP.
Date: Fri, 22 Jul 2011 17:32:12 +0100

Hi Jim,

> > On 07/20/2011 07:34 AM, Ralph Corderoy wrote:
> > > BTW, the code for the built-in printf has a bug.  For negative
> > > field-widths it negates a negative integer without checking it
> > > will fit.  E.g. on this 64-bit machine
> > >
> > >      $ printf '%-9223372036854775808s.\n' foo
> > >      foo.
> > >      $
> >
> > Coreutils' printf shares this misfortune.  Sadly, it might even be a
> > bug in the underlying glibc printf(), although I haven't tried to
> > write a test program to check that, yet.
> This is not about a negative field width.

Just to ensure there's no confusion, as far as bash's built-in printf is
concerned one aspect of it is about a negative field width since

    $ printf '.%*q.\n' -10 foo
    .foo       .

is implemented by converting the "-10" into a number, spotting it's
negative, setting the left-justified flag, and then negating the number.

Coreutils' printf doesn't have that particular issue since it passes the
negative number to the C library as a negative and has it deal with the
justification change.  For %b, which libc doesn't support, coreutils

      /* FIXME: Field width and precision are not supported
         for %b, even though POSIX requires it.  */

so there's no code to go wrong.  :-)

Cheers, Ralph.

reply via email to

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