Re: [HACKERS] OID from insert has extra letter

2001-02-06 Thread Tom Lane
"Ross J. Reedstrom" <[EMAIL PROTECTED]> writes: > Seems it's a non-portable behavior: Not at all. The code is asking strncpy to copy n bytes, where n is known to be <= strlen of the source string. Every spec-conforming implementation of strncpy will copy n bytes, no more, no less, and will *not

Re: [HACKERS] OID from insert has extra letter

2001-02-06 Thread Ross J. Reedstrom
On Tue, Feb 06, 2001 at 06:17:46PM -0600, Ross J. Reedstrom wrote: > > Seems it's a non-portable behavior: > > The strncpy() function is similar, except that not more >than n bytes of src are copied. Thus, if there is no null >byte among the first n bytes of src, the re

Re: [HACKERS] OID from insert has extra letter

2001-02-06 Thread Ross J. Reedstrom
On Tue, Feb 06, 2001 at 07:08:20PM -0500, Tom Lane wrote: > [EMAIL PROTECTED] (Nathan Myers) writes: > > Thus, the original code is OK, except probably the literal "23" > > in place of what should be a meaningful symbolic constant, or > > (at least!) sizeof(buf) - 1. > > No, the original code is

Re: [HACKERS] OID from insert has extra letter

2001-02-06 Thread Tom Lane
[EMAIL PROTECTED] (Nathan Myers) writes: > Thus, the original code is OK, except probably the literal "23" > in place of what should be a meaningful symbolic constant, or > (at least!) sizeof(buf) - 1. No, the original code is NOT ok. Read the man page again. As the code stood, the only null th

Re: [HACKERS] OID from insert has extra letter

2001-02-06 Thread Nathan Myers
On Tue, Feb 06, 2001 at 01:21:00PM -0500, Bruce Momjian wrote: > > > *** 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; > > > s

Re: [HACKERS] OID from insert has extra letter

2001-02-06 Thread Ross J. Reedstrom
On Tue, Feb 06, 2001 at 01:21:00PM -0500, Bruce Momjian wrote: > What if len < 23? mea culpa. Must go eat lunch. No sugar to brain. (and no, I didn't put the original error in :-) Ross

Re: [HACKERS] OID from insert has extra letter

2001-02-06 Thread Bruce Momjian
> > *** 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; >

Re: [HACKERS] OID from insert has extra letter

2001-02-06 Thread Ross J. Reedstrom
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 >

Re: [HACKERS] OID from insert has extra letter

2001-02-05 Thread Tom Lane
[EMAIL PROTECTED] (D'Arcy J.M. Cain) writes: > Get: 31930584, should be 3193058 > Get: 31943386, should be 3194338 > As you can see, there is an extra digit added. I am using PQoidStatus() > to get the OID. Is this the right way? Is it possible that there is > a buffer/terminating problem in t