freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: ZIGLIO Frediano <Frediano.Ziglio AT vodafoneomnitel.it>
- To: "'TDS Development Group'" <freetds AT franklin.metalab.unc.edu>
- Subject: RE: Losing last character of TEXT fields
- Date: Tue, 9 Jul 2002 09:44:21 +0200
>
> > On your say-so, I'll revert those lines to their 1.12
> arrangement. You
> > fixed the problem and Brian's pretty sure the 1.13 effect
> was mistaken.
> > I'll even reinstate your calling card for future reference.
>
> The function I reverted was "tds_convert_text". I committed
> version 1.21;
> see the patch below.
>
> --jkl
>
>
> @@ -107,6 +107,7 @@
> return srctype;
> }
>
> +/* reverted function to 1.12 logic; 1.13 patch was mistaken.
> July 2002
> jkl */
> static TDS_INT
> tds_convert_text(int srctype,TDS_CHAR *src,TDS_UINT srclen,
> int desttype,TDS_CHAR *dest,TDS_UINT destlen)
> @@ -115,18 +116,20 @@
>
> switch(desttype) {
> case SYBTEXT:
> - case SYBCHAR:
> cplen = srclen > destlen ? destlen : srclen;
> memcpy(dest, src, cplen);
> - dest[cplen-1] = '\0';
> + /* 2001-06-15 Deutsch changed [cplen-1] to [cplen] */
> + dest[cplen] = '\0';
> return strlen(dest);
> - case SYBBINARY:
> + case SYBCHAR:
> cplen = srclen > destlen ? destlen : srclen;
> memcpy(dest, src, cplen);
> - return cplen;
> + dest[cplen]='\0';
> + return strlen(dest);
> }
> return 0;
> }
> +
> static TDS_UINT
> utf16len(const utf16_t* s)
> {
>
I'm not agree. I prefer loosing a character to a buffer overflow.
Perhaps seem that definition of srclen and destlen is different.
srclen is the len of input string without counting terminator (there is no
terminator) while destlen if the len of the output buffer counting needed
terminator.
Is that right ?
Then cplen should be the minimun of srclen and (destlen-1)
That for read a varchar(255) we must pass a 256 char buffer.
freddy77
=================================
"STRICTLY PERSONAL AND CONFIDENTIAL
This message may contain confidential and proprietary material for the sole
use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you are not the intended recipient please contact
the sender and delete all copies.
The contents of this message that do not relate to the official business of
our company shall be understood as neither given nor endorsed by it."
=================================
-
Losing last character of TEXT fields,
L J Bayuk, 07/07/2002
- <Possible follow-up(s)>
- RE: Losing last character of TEXT fields, Lowden, James K, 07/08/2002
- RE: Losing last character of TEXT fields, Eric Deutsch, 07/08/2002
- RE: Losing last character of TEXT fields, Brian Bruns, 07/08/2002
- RE: Losing last character of TEXT fields, Lowden, James K, 07/08/2002
- RE: Losing last character of TEXT fields, James K. Lowden, 07/08/2002
- RE: Losing last character of TEXT fields, ZIGLIO Frediano, 07/09/2002
- RE: Losing last character of TEXT fields, Bill Thompson, 07/09/2002
- RE: Losing last character of TEXT fields, Lowden, James K, 07/09/2002
- RE: Losing last character of TEXT fields, Bill Thompson, 07/09/2002
- RE: Losing last character of TEXT fields, Brian Bruns, 07/09/2002
- RE: Losing last character of TEXT fields, Lowden, James K, 07/09/2002
- RE: Losing last character of TEXT fields, Eric Deutsch, 07/09/2002
- RE: Losing last character of TEXT fields, Brian Bruns, 07/09/2002
- RE: Losing last character of TEXT fields, Eric Deutsch, 07/09/2002
- RE: Losing last character of TEXT fields, Michael Peppler, 07/09/2002
- RE: Losing last character of TEXT fields, Lowden, James K, 07/09/2002
Archive powered by MHonArc 2.6.24.