On Mon, Feb 05, 2001 at 09:17:45PM -0500, Tom Lane wrote:
>
> Yes, on looking at it I see that someone broke PQoidStatus() in 7.0.
> If you want to fix your copy, the patch (line numbers are for current
> CVS) is
>
> Index: fe-exec.c
> ===================================================================
> RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v
> retrieving revision 1.98
> retrieving revision 1.100
> diff -c -r1.98 -r1.100
> *** fe-exec.c 2001/01/24 19:43:30 1.98
> --- fe-exec.c 2001/02/06 02:02:27 1.100
> ***************
> *** 2035,2041 ****
> if (len > 23)
> len = 23;
> strncpy(buf, res->cmdStatus + 7, len);
> ! buf[23] = '\0';
>
> return buf;
> }
> --- 2035,2041 ----
> if (len > 23)
> len = 23;
> strncpy(buf, res->cmdStatus + 7, len);
> ! buf[len] = '\0';
>
> return buf;
> }
>
Hmm, is there some undocumented feature of strncpy that I don't know
about, where it modifies the passed length variable (which would be hard,
since it's pass by value)? Otherwise, doesn't this patch just replace
the constant '23' with the variable 'len', set to 23?
Ross