[Bug 229641] /usr/bin/printf (so also internal printf in sh) ignores width and precision in %b format

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 229641] /usr/bin/printf (so also internal printf in sh) ignores width and precision in %b format

bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229641

            Bug ID: 229641
           Summary: /usr/bin/printf (so also internal printf in sh)
                    ignores width and precision in %b format
           Product: Base System
           Version: 11.1-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: [hidden email]
          Reporter: [hidden email]

/usr/bin/printf (so also internal printf in sh) ignores width and precision in
%b format. The change is since commit base r265706 (May 2014), where macro PF()
with width and precision interpretation has been replaced by direct call to
fputs(), so width and precision are ignored now.

Expected result, for example from bash:

bash$ printf "%8.2b" "a\nb\n"
      a

Bad result from /usr/bin/printf and from sh:

sh$ /usr/bin/printf "%8.2b" "a\nb\n"
a
b

sh$ printf "%8.2b" "a\nb\n"
a
b

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 229641] /usr/bin/printf (so also internal printf in sh) ignores width and precision in %b format

bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229641

Mark Linimon <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email],
                   |                            |[hidden email]
           Keywords|                            |regression

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 229641] /usr/bin/printf (so also internal printf in sh) ignores width and precision in %b format

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229641

--- Comment #1 from Pedro F. Giffuni <[hidden email]> ---
Created attachment 195011
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=195011&action=edit
Possible fix

Fix submitted by Garrett D'Amore.

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 229641] /usr/bin/printf (so also internal printf in sh) ignores width and precision in %b format

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229641

Pedro F. Giffuni <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #195011|0                           |1
        is obsolete|                            |

--- Comment #2 from Pedro F. Giffuni <[hidden email]> ---
Created attachment 195012
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=195012&action=edit
Possible fix + copyright update

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 229641] /usr/bin/printf (so also internal printf in sh) ignores width and precision in %b format

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229641

Mark Linimon <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 229641] /usr/bin/printf (so also internal printf in sh) ignores width and precision in %b format

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229641

Jilles Tjoelker <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|New                         |Open

--- Comment #3 from Jilles Tjoelker <[hidden email]> ---
This looks like a valid bug.

This change should have some tests. The printf utility already has tests so
adding tests for this bug seems appropriate.

The copy of the format string is unnecessary as `start` is already a copy.
Getting rid of it would also fix the bug that there is a memory leak if the
allocation for bfmt succeeds but the allocation for p fails.

(On another note, `start` can be a rather large allocation on the stack.
Ideally, no space would be reserved past the specifier such as b, c, s.)

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[hidden email]"
Reply | Threaded
Open this post in threaded view
|

[Bug 229641] /usr/bin/printf (so also internal printf in sh) ignores width and precision in %b format

bugzilla-noreply
In reply to this post by bugzilla-noreply
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229641

Pedro F. Giffuni <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
 Attachment #195012|0                           |1
        is obsolete|                            |

--- Comment #4 from Pedro F. Giffuni <[hidden email]> ---
Created attachment 195131
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=195131&action=edit
Take 2

Something like this (Not sure about the test).

--
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
[hidden email] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[hidden email]"