Skip to Content.
Sympa Menu

freetds - RE: [freetds] Small patch

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Small patch
  • Date: Fri, 14 Nov 2003 13:28:59 -0500

> From: ZIGLIO Frediano [mailto:Frediano.Ziglio AT vodafone.com]
> Sent: November 14, 2003 7:41 AM
>
> This patch should fix the problem with db-lib.
>
> * freetds62/doc/api_status.txt: update
> * freetds62/src/tds/iconv.c freetds62/src/tds/read.c:
> - fix problem with iconv
>
> In iconv.c *inbuf and *inbytesleft were already updated in
> skip_one_input_sequence; this caused a E2BIG problem (and
> also a buffer overflow in iconv !!!)

OK, I can apply that. Thanks for hunting it down!

> I updates also read_and_convert to discard the rest of string if
> provided buffer is insufficient. This prevent lost of sync between
> FreeTDS and server.

I changed read_and_convert() yesterday. Your patch is against the previous
version. Could you take a look at what I did? I fixed some other problems,
in addition to changing some names. If you don't have access to current
CVS, use http://www.schemamania.org/projects/freetds/src/tds/read.c.

The real question is: Do we want read_and_convert() to discard data? Or
should the caller re-issue the read when it gets the error? There are three
errors to consider:

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.

2. tds_iconv() treats EILSEQ correctly for the purpose of
read_and_convert(). tds_iconv() will generate an error message and convert
(as best it can) the whole input buffer. read_and_convert() can ignore
EILSEQ.

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.

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.

--jkl
-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.






Archive powered by MHonArc 2.6.24.

Top of Page