Patch to fix uClibc++ stream issue
Bernhard Reutner-Fischer
rep.dot.nop at gmail.com
Fri Aug 22 13:39:52 UTC 2008
Hi Peter,
On Fri, Aug 22, 2008 at 03:37:53PM +0300, Peter Nixon wrote:
>There is an issue in uClibc++ stream handling.
>
>Two problems:
>
>The fill character is uninitialized in one form of the ios constructor, so
>sometimes output is filled with a random character rather than a space.
>
>Unfortunately the test of the format flags == right is not the same flags
>!= left, so code was rearranged to guarantee that if it is not left aligned
>then it must be right aligned.
>
>Background: This bug in uclibc++ causes OPAL to fail SIP authentication with
>a registrar if the MD5 Digest has a leading zero, but not otherwise. (Lots
>of fun to track down!!)
>
>Index: include/ostream
>===================================================================
>--- include/ostream (revision 1735)
>+++ include/ostream (working copy)
>@@ -130,17 +130,17 @@
> }
>
> _UCXXEXPORT void printout(const char_type* s, streamsize n)
>- {
>- int extra = ios::width() - n;
>+ {
>+ bool printfirst = (ios::flags()&ios::adjustfield) == ios::left;
>+ if (printfirst)
>+ write(s, n);
>+ int extra = ios::width() - n;
>+ while (extra-- > 0)
>+ put(ios::fill());
>+ if (!printfirst)
>+ write(s, n);
>+ ios::width(0);
>+ }
Can you somehow rephrase this to a) put all declarations to the top
since this style seems to be used everywhere else, b) rename printfirst
to left_aligned or left_aligned for clarity, c) try to come up with just
one call to write(), d) retain the indentation ?
More information about the uClibc
mailing list