pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: bianpan2016@163.com
To: pgsql-bugs@postgresql.org
Cc: bianpan2016@163.com
Subject: BUG #14929: Unchecked AllocateDir() return value in restoreTwoPhaseData()
Date: Mon, 27 Nov 2017 09:31:07 +0000
Message-ID: <20171127093107.1473.70477@wrigleys.postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      14929
Logged by:          Pan Bian
Email address:      bianpan2016@163.com
PostgreSQL version: 10.1
Operating system:   Linux
Description:        

File: src/backend/access/transam/twophase.c
Function: restoreTwoPhaseData
Line: 1738

AllocateDir() will return a NULL pointer if it fails to open the specified
directory. However, in function restoreTwoPhaseData(), its return value is
not checked. This may result in a NULL pointer dereference when trying to
free it (see line 1759).

For your convenience, I copy and paste related codes as follows:

1732 void
1733 restoreTwoPhaseData(void)
1734 {
1735     DIR        *cldir;
1736     struct dirent *clde;
1737 
1738     cldir = AllocateDir(TWOPHASE_DIR);
1739     LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1740     while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
1741     {
         ...
1758     LWLockRelease(TwoPhaseStateLock);
1759     FreeDir(cldir);
1760 }

Thank you!

Pan Bian



view thread (10+ messages)  latest in thread

Message-ID: <20171127093107.1473.70477@wrigleys.postgresql.org>
Permalink:  ../20171127093107.1473.70477@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20171127093107.1473.70477@wrigleys.postgresql.org

 · 

reply

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: bianpan2016@163.com
  Subject: Re: BUG #14929: Unchecked AllocateDir() return value in restoreTwoPhaseData()
  In-Reply-To: <20171127093107.1473.70477@wrigleys.postgresql.org>
  References: <20171127093107.1473.70477@wrigleys.postgresql.org>

* 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