Re: [PATCH] avoid buffer underflow in errfinish()

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Xi Wang <xi(dot)wang(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] avoid buffer underflow in errfinish()
Date: 2013-03-27 12:45:51
Message-ID: CA+Tgmob3JFiLWSAuRTBWybiQx-ucHzMkHwHzMGy9anOZmBLvUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Mar 23, 2013 at 6:38 PM, Xi Wang <xi(dot)wang(at)gmail(dot)com> wrote:
> CHECK_STACK_DEPTH checks if errordata_stack_depth is negative.
> Move the dereference of &errordata[errordata_stack_depth] after
> the check to avoid out-of-bounds read.

This seems sensible and I'm inclined to commit it. It's unlikely to
matter very much in practice, since the only point of checking the
stack depth in the first place is to catch a seemingly-unlikely coding
error; and it's unlikely that referencing beyond the stack bounds
would do anything too horrible, either. But we may as well do it
right.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2013-03-27 12:50:16 Re: [PATCH] avoid buffer underflow in errfinish()
Previous Message Thom Brown 2013-03-27 12:44:31 Re: pgsql: sepgsql: Support for new post-ALTER access hook.