From: Tom Lane <tgl@sss.pgh.pa.us>
To: bianpan2016@163.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14931: Unchecked attnum value in ATExecAlterColumnType()
Date: Mon, 27 Nov 2017 20:37:16 -0500
Message-ID: <22670.1511833036@sss.pgh.pa.us> (raw)
In-Reply-To: <20171127095339.1464.29304@wrigleys.postgresql.org>
References: <20171127095339.1464.29304@wrigleys.postgresql.org>
bianpan2016@163.com writes:
> File: src/backend/commands/tablecmds.c
> Function: ATExecAlterColumnType
> Line: 8986
> The value of field attTup->attnum may be zero or even negative. However, in
> function ATExecAlterColumnType(), its value is incorrectly assumed to be
> larger than or equal to 1. In an exceptional case, it may lead to a buffer
> overflow bug (see lines 8989 and 8990).
I do not think this is a real problem, because ATPrepAlterColumnType
has already checked for attnum <= 0 (at line 8826, in HEAD). If
ATExecAlterColumnType can't assume that ATPrepAlterColumnType has
already been run, we have more problems than this.
> I also collect a function (i.e. ATExecDropNotNull) in the same file as an
> example, shown as follows:
The division of labor between Prep and Exec functions isn't very uniform
in this file. That may not be a great thing stylistically, but if we
decide it's something to improve, it'd have to be done holistically not
one point at a time.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, bianpan2016@163.com
Subject: Re: BUG #14931: Unchecked attnum value in ATExecAlterColumnType()
In-Reply-To: <22670.1511833036@sss.pgh.pa.us>
References: <20171127095339.1464.29304@wrigleys.postgresql.org> <22670.1511833036@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox