Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbcf188a

Browse files
committed
Fix SPI_getvalue and SPI_getbinval to range-check the given attribute number
according to the TupleDesc's natts, not the number of physical columns in thetuple. The previous coding would do the wrong thing in cases where natts isdifferent from the tuple's column count: either incorrectly report error whenit should just treat the column as null, or actually crash due to indexing offthe end of the TupleDesc's attribute array. (The second case is probably notpossible in modern PG versions, due to more careful handling of inheritancecases than we once had. But it's still a clear lack of robustness here.)The incorrect error indication is ignored by all callers within the core PGdistribution, so this bug has no symptoms visible within the core code, butit might well be an issue for add-on packages. So patch all the way back.
1 parentce0fb50 commitbcf188a

File tree

1 file changed

+3
-3
lines changed
  • src/backend/executor

1 file changed

+3
-3
lines changed

‎src/backend/executor/spi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.198 2008/09/1523:37:39 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/spi.c,v 1.199 2008/10/16 13:23:21 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -743,7 +743,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
743743

744744
SPI_result=0;
745745

746-
if (fnumber>HeapTupleHeaderGetNatts(tuple->t_data)||fnumber==0||
746+
if (fnumber>tupdesc->natts||fnumber==0||
747747
fnumber <=FirstLowInvalidHeapAttributeNumber)
748748
{
749749
SPI_result=SPI_ERROR_NOATTRIBUTE;
@@ -784,7 +784,7 @@ SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
784784
{
785785
SPI_result=0;
786786

787-
if (fnumber>HeapTupleHeaderGetNatts(tuple->t_data)||fnumber==0||
787+
if (fnumber>tupdesc->natts||fnumber==0||
788788
fnumber <=FirstLowInvalidHeapAttributeNumber)
789789
{
790790
SPI_result=SPI_ERROR_NOATTRIBUTE;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp