Re: contrib/ buffer paranoia - Mailing list pgsql-patches

From Alvaro Herrera
Subject Re: contrib/ buffer paranoia
Date
Msg-id Pine.LNX.4.44.0208121520520.9126-100000@cm-lcon1-46-187.cm.vtr.net
Whole thread Raw
In response to Re: contrib/ buffer paranoia  (Neil Conway <nconway@klamath.dyndns.org>)
Responses Re: contrib/ buffer paranoia  (Neil Conway <nconway@klamath.dyndns.org>)
List pgsql-patches
Neil Conway dijo:

> Alvaro Herrera <alvherre@atentus.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.

I agree.  Maybe it worked out of pure luck (or some alignment magic).
But while you're at it, you can as well correct the bug.

--
Alvaro Herrera (<alvherre[a]atentus.com>)
"Hay quien adquiere la mala costumbre de ser infeliz" (M. A. Evans)


pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: Re: contrib/ buffer paranoia
Next
From: Peter Eisentraut
Date:
Subject: Re: Antw: Re: Patch for NetWare support