Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)

From: Mahendra Singh Thalor <mahi6run(at)gmail(dot)com>
To: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix uninitialized variable access (src/backend/utils/mmgr/freepage.c)
Date: 2021-07-01 20:19:58
Message-ID: CAKYtNAoUu1_jizdzP1qF7anW=ijN6MsP1eFPB7Qy7k4EL+x6UA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2 Jul 2021 at 01:13, Ranier Vilela <ranier(dot)vf(at)gmail(dot)com> wrote:
>
> Hi,
>
> The function FreePageManagerPutInternal can access an uninitialized
variable,
> if the following conditions occur:

Patch looks good to me.

> 1. fpm->btree_depth != 0
> 2. relptr_off == 0 inside function (FreePageBtreeSearch)
>
> Perhaps this is a rare situation, but I think it's worth preventing.

Please can we try to hit this rare condition by any test case. If you have
any test cases, please share.

1064 FreePageBtreeSearch(FreePageManager *fpm, Size first_page,

1065 FreePageBtreeSearchResult *result)

1066 {

1067 char *base = fpm_segment_base(fpm);

1068 FreePageBtree *btp = relptr_access(base, fpm->btree_root);

1069 Size index;

1070

1071 result->split_pages = 1;

1072

1073 /* If the btree is empty, there's nothing to find. */

1074 if (*btp == NULL*)

1075 {

1076 result->page = NULL;

1077 result->found = false;

1078 return;

1079 }

>
> /* Search the btree. */
> FreePageBtreeSearch(fpm, first_page, &result);
> Assert(!result.found);
> if (result.index > 0) /* result.index is garbage or invalid here) */
>
> regards,
> Ranier Vilela

--
Thanks and Regards
Mahendra Singh Thalor
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2021-07-01 20:22:34 Re: make world and install-world without docs
Previous Message Dean Rasheed 2021-07-01 19:45:04 Re: rand48 replacement