Re: Bug in convert.c copy_and_convert_field

From: Paul Cochrane <paul(dot)m(dot)cochrane(at)tuht(dot)scot(dot)nhs(dot)uk>
To: pgsql-odbc(at)postgresql(dot)org
Subject: Re: Bug in convert.c copy_and_convert_field
Date: 2005-02-11 18:06:27
Message-ID: 420CF423.1090403@tuht.scot.nhs.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

Paul Cochrane wrote:

> Hi again list.
>
> I think I've encountered a bug in the file convert.c -
> copy_and_convert_field procedure. Unfortunately my C is a little out
> of practise not having done it for 10 years or so. Can anyone help? I
> think I've traced the error to the default part of the switch around
> line 850 (that where the dodgy lines are being placed in the mylog
> file so it's somewhere before that). Below is a snippet of the mylog
> showing the problem. The lines where it is saying DEFAULT: & the ptr
> part of the string. In some cases this is correct but in others there
> are lots of extra / strange characters. The len field always seems to
> be correct however.
>
> The log file ends with a single ' which may explain the error I get on
> the server (1) could not receive data from client: Connection reset by
> peer and (2) unexpected EOF on client connection
>
I've found a quick fix to this problem. I've simply added a line:

strncpy(ptr+len, "\0", 1);

just before the mylog line on line 850 of convert.c. I believe this
simply ensures that there is a NULL at the end of the string stored in
ptr. There may be a more elegant way to do this but it seems to work.

Now onto the next fault cause it fails again shortly after this.
Bugger! :-(

Paul

--
Paul Cochrane (paul(dot)m(dot)cochrane(at)tuht(dot)scot(dot)nhs(dot)uk)
+--------------------------------------------------------
| Tayside Orthopaedic & Rehabilitation Technology Centre
| Ninewells Hospital & Medical School
| Dundee, Scotland, UK.
| DD1 9SY
| Phone: Internal: 36284
| External: +44 (1382) 496284
| Fax: +44 (1382) 496322
+--------------------------------------------------------

In response to

Browse pgsql-odbc by date

  From Date Subject
Next Message Dave Page 2005-02-11 21:14:06 Re: Bug in convert.c copy_and_convert_field
Previous Message Paul Cochrane 2005-02-11 17:28:28 Bug in convert.c copy_and_convert_field