Re: pgsql: Support opfamily members in get_object_address

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-committers(at)postgresql(dot)org
Subject: Re: pgsql: Support opfamily members in get_object_address
Date: 2015-03-16 20:41:15
Message-ID: 55073FEB.6040404@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On 3/16/15 11:07 AM, Alvaro Herrera wrote:
> Support opfamily members in get_object_address

I get compiler warnings from this:

objectaddress.c: In function ‘get_object_address’:
objectaddress.c:1428:12: warning: array subscript is above array bounds
[-Warray-bounds]
objectaddress.c:1430:11: warning: array subscript is above array bounds
[-Warray-bounds]

This looks fishy:

1423 i = 0;
1424 foreach (cell, objargs)
1425 {
1426 ObjectAddress typaddr;
1427
1428 typenames[i] = strVal(lfirst(cell));
1429 typaddr = get_object_address_type(OBJECT_TYPE, cell, missing_ok);
1430 typeoids[i] = typaddr.objectId;
1431 if (i++ >= 2)
1432 break;
1433 }

Since you're using a postfix increment, the loop will execute with i =
2, which will lead to the array bounds violation.

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2015-03-17 01:55:50 pgsql: Fix out-of-array-bounds compiler warning
Previous Message Alvaro Herrera 2015-03-16 15:07:13 pgsql: Support opfamily members in get_object_address

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-03-16 20:43:32 Re: Additional role attributes && superuser review
Previous Message Jim Nasby 2015-03-16 20:34:11 Re: pg_xlog_replay_resume() considered armed and dangerous