Skip to Content.
Sympa Menu

freetds - Re: [freetds] read_and_convert() (was: Small patch)

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT schemamania.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] read_and_convert() (was: Small patch)
  • Date: Sat, 15 Nov 2003 14:20:17 -0500

On Sat, 15 Nov 2003 01:56:39 -0800, "Frediano Ziglio"
<freddyz77 AT lycos.com> wrote:
>
> >1. E2BIG. IMO, the buffer passed to this low-level routine should
> >*always* be big enough. Nothing should be discarded and no error ever
> >returned. Just assert() and die. After all, you found the real error,
> >in iconv.c.
>
> In current implementation text buffer is insufficient and should be
> resized (see utf8_1 test). Also is not so expensive to handle this case.
> I prefer to handle strange case (like 40 characters returned for a
> varchar(1)) due to man-in-the-middle attacks or other strange events.

"40 characters returned for a varchar(1)" ??

I agree we should resize the buffer for [n]text data. No reason to return
E2BIG, though.

> >3. EINVAL. Should not happen. read_and_convert() has enough
> >information to avoid asking tds_iconv() to convert an incomplete
> >character. If it fails to do so, it should assert() and die. We need
> >to correct any such logic error.
>
> EINVAL can be raised from an invalid input sequence, not only an
> incomplete one. In this case we cannot skip character...

Depending on the iconv library, you mean?

Whatever variations we find among libiconv implementations, tds_iconv()
should be made to return consistent errno values.

> >In short, read_and_convert() should be made totally reliable, never
> >returning a conversion error. If it doesn't abort, it should return a
> >best-effort fully converted buffer, and leave the TDS stream in sync
> >with the server.
> >
> >Communication errors are another matter, but tds_get_n() doesn't return
> >those.
>
> We should also handle the case of a long string with strange
> unconvertible characters. In this case (and current implementation) we
> issue multiple warnings due to wrong conversion..

Right and right. tds_iconv() should never emit duplicate messages per
call. One is plenty.

I think I can fix read_and_convert() today to detect UTF-8 inputs and DTRT
with character alignment.

--jkl





Archive powered by MHonArc 2.6.24.

Top of Page