PR bin/59167 fix question

Aristarkh A Zagorodnikov xm at x-infinity.com
Tue Nov 11 00:10:01 PST 2003


		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



More information about the freebsd-hackers mailing list