Re: contrib/ buffer paranoia

From: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
To: Alvaro Herrera <alvherre(at)atentus(dot)com>
Cc: PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: contrib/ buffer paranoia
Date: 2002-08-12 18:51:24
Message-ID: 874rdzykpf.fsf@klamath.dyndns.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Alvaro Herrera <alvherre(at)atentus(dot)com> writes:
> I think in dbase/dbf2pg.c the limit of 10 to pgdate should be 11
> (snprintf counts the \0 at the end).

Yes, but so does the array declaration itself: a char[10] can hold at
most 9 characters plus the '\0' terminator. I think the original code
is buggy: if the author wants to store 10 characters plus a terminator
in the array, it should be declared as a char[11]. Using snprintf() of
length 11 with a char[10] would allow for a one-character overrun.

(Or did I not drink enough coffee this morning? :-) )

Cheers,

Neil

--
Neil Conway <neilconway(at)rogers(dot)com>
PGP Key ID: DB3C29FC

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Alvaro Herrera 2002-08-12 19:22:35 Re: contrib/ buffer paranoia
Previous Message Alvaro Herrera 2002-08-12 18:33:37 Re: contrib/ buffer paranoia