Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Nov 2003 11:09:09 +0300
From:      "Aristarkh A Zagorodnikov" <xm@x-infinity.com>
To:        <hackers@freebsd.org>
Subject:   PR bin/59167 fix question
Message-ID:  <000001c3a82b$1a678d80$0600a8c0@XMWXP>

Next in thread | Raw E-Mail | Index | Archive | Help

		Hi!

	Recently, I submitted PR bin/59167 and I'm interested in the
preferred way of fixing it.
	Below, I duplicate the "Fix" section of submitted PR for your
convenience.

Note that the following conclusions are made after only a brief looking =
at
the problem code so they may be partially or event completely wrong.

The fix involves support for __SSTR and __SALC FILE flags in output =
function
which is called from internal formatting function
__vfwprintf. Currently, __vfwprintf uses __fputwc for output, which in =
turn
uses __sputc which blindly writes characters and
calls __swbuf when buffer is exhausted. In contrast, single-character
internal formatting function __vfprintf uses __sfvwrite function
to write output, which correctly handles __SSTR and __SALC FILE flags
(reallocating the buffer) and does not exhibit the problem.

So, proposed solutions are:
1. rewrite __vfwprintf output to use something other than __fputwc (i.e. =
use
__sfvwrite with some wcs->mbcs preprocessing?)
2. fix __fputwc to support the __SSTR and __SALC flags (bad idea, this
function should be fast)
3. fix __swbuf to support the __SSTR and __SALC flags (looks good to me,
especially because it's called at the exact time when buffer is about to
overflow)

I already concluded a quick patch using (3), but not tested it good =
enough,
so I'm not posting it here.
If someone considers that my patch can be of any value, I will gladly =
submit
it for review.

Aristarkh A Zagorodnikov
X-Infinity Software



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?000001c3a82b$1a678d80$0600a8c0>