Skip to Content.
Sympa Menu

freetds - RE: [freetds] HP/UX and iconv

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: christos AT zoulas.com (Christos Zoulas)
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] HP/UX and iconv
  • Date: Fri, 12 Dec 2003 14:54:34 -0500

On Dec 12, 2:43pm, LowdenJK AT bernstein.com ("Lowden, James K") wrote:
-- Subject: RE: [freetds] HP/UX and iconv

| > From: Marquess, Dustin [mailto:Dustin.Marquess AT allegiancetelecom.com]
| > Sent: December 12, 2003 1:45 PM
| >
| > Sounds like some code that is not 64-bit clean. If you
| > compile FreeTDS with
| > the cc compiler with the -taso -xtaso options, it will
| > probably work around
| > these problems.
| >
| > You should be able to run gdb or ladebug against those memory
| > locations to
| > find the culprit.
|
| Thanks, Dustin. You're absolutely right. I just read uac(1); I haven't
| found the gcc switch, if it exists, to align things.
|
| Here's an example. In write.c::tds_put_string:
|
| tds_put_string(TDSSOCKET * tds, const char *s, int len)
| {
| TDS_ENCODING *client, *server;
| char outbuf[256], *poutbuf;
| unsigned int inbytesleft, outbytesleft, bytes_out = 0;
| [...]
| if (-1 == tds_iconv(tds, tds->iconv_info[client2ucs2], to_server,
| &s, &inbytesleft, &poutbuf, &outbytesleft))
|
|
| We take the address of outbytesleft. Because it's declared behind an int,
| it's on a 4-byte boundary. Inside the iconv() function (our replacement),
| there's this line:
|
| copybytes = (*inbytesleft < *outbytesleft)? *inbytesleft :
| *outbytesleft;
|
| which generates a fixup message, see below. What to do?

Fix the bug in the code :-) tds_iconv expects "size_t *", and you
are passing it "unsigned int *". This will break on LP64 systems
where size_t is unsigned long and sizeof(long) != sizeof(int).

so s/unsigned int/size_t/ in the above snippet and you are all set.

christos




Archive powered by MHonArc 2.6.24.

Top of Page