Re: OID from insert has extra letter

Поиск
Список
Период
Сортировка
От Ross J. Reedstrom
Тема Re: OID from insert has extra letter
Дата
Msg-id 20010206181746.A22539@rice.edu
обсуждение исходный текст
Ответ на Re: OID from insert has extra letter  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: OID from insert has extra letter  ("Ross J. Reedstrom" <reedstrm@rice.edu>)
Re: OID from insert has extra letter  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Tue, Feb 06, 2001 at 07:08:20PM -0500, Tom Lane wrote:
> ncm@zembu.com (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 that ever got written to the buffer was the
> one installed in buf[23].  The only reason it appeared to work at all
> was that buf would start out all zeroes --- but after one or more uses
> it's not all zeroes anymore.  See the bug report that started the
> thread ...

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 result wil not be      null-terminated.
 
      In the case where the length of src is less than  that  of      n, the remainder of dest will be padded with
nulls.

I've already forgotten what platform the original bug report came from.

Ross


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: OID from insert has extra letter
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Include files for SPI are not installed