| From: | PanBian <bianpan2016(at)163(dot)com> | 
|---|---|
| To: | Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp> | 
| Cc: | pgsql-bugs(at)postgresql(dot)org | 
| Subject: | Re: BUG #14928: Unchecked SearchSysCacheCopy1() return value | 
| Date: | 2017-11-27 11:36:52 | 
| Message-ID: | 20171127113652.GB30475@bp | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-bugs | 
On Mon, Nov 27, 2017 at 07:21:32PM +0900, Amit Langote wrote:
> On 2017/11/27 18:13, bianpan2016(at)163(dot)com wrote:
> > The following bug has been logged on the website:
> > 
> > Bug reference:      14928
> > Logged by:          Pan Bian
> > Email address:      bianpan2016(at)163(dot)com
> > PostgreSQL version: 10.1
> > Operating system:   Linux
> > Description:        
> > 
> 
> Thanks for the report.  Attached a patch that adds a check that tuple is
> valid before trying to dereference it.
> 
> Thanks,
> Amit
> 
Got it.
Thanks a lot,
Pan Bian
> diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
> index d19846d005..8cd6c65111 100644
> --- a/src/backend/commands/tablecmds.c
> +++ b/src/backend/commands/tablecmds.c
> @@ -14111,6 +14111,9 @@ ATExecDetachPartition(Relation rel, RangeVar *name)
>  	classRel = heap_open(RelationRelationId, RowExclusiveLock);
>  	tuple = SearchSysCacheCopy1(RELOID,
>  								ObjectIdGetDatum(RelationGetRelid(partRel)));
> +	if (!HeapTupleIsValid(tuple))
> +		elog(ERROR, "cache lookup failed for relation %u",
> +					RelationGetRelid(partRel));
>  	Assert(((Form_pg_class) GETSTRUCT(tuple))->relispartition);
>  
>  	(void) SysCacheGetAttr(RELOID, tuple, Anum_pg_class_relpartbound,
| From | Date | Subject | |
|---|---|---|---|
| Next Message | PanBian | 2017-11-27 11:44:10 | Re: BUG #14929: Unchecked AllocateDir() return value in restoreTwoPhaseData() | 
| Previous Message | PanBian | 2017-11-27 11:34:51 | Re: BUG #14927: Unchecked SearchSysCache1() return value |