Re: merge file_exists_in_directory and _fileExistsInDirectory functions and move into common file dumputils.c - Mailing list pgsql-hackers

From Álvaro Herrera
Subject Re: merge file_exists_in_directory and _fileExistsInDirectory functions and move into common file dumputils.c
Date
Msg-id 202504110938.4kx73ylnv6p4@alvherre.pgsql
Whole thread Raw
In response to Re: merge file_exists_in_directory and _fileExistsInDirectory functions and move into common file dumputils.c  (Michael Paquier <michael@paquier.xyz>)
Responses Re: merge file_exists_in_directory and _fileExistsInDirectory functions and move into common file dumputils.c
List pgsql-hackers
On 2025-Apr-11, Michael Paquier wrote:

> Perhaps we should just use a more centralized place, like file_utils.c
> so as all frontends could benefit of it?

I'm not sure about that.  This code looks to be making too many
assumptions that aren't acceptable for a general routine, such as
complaining only that the directory name is long without the possibility
that the culprit is the file name.  It's more or less okay in current
uses because they're all using harcoded short names, but that would not
hold in general.  At the same time, isn't every call of this routine a
potential TOCTTOU bug?  Again it's probably fine for the current code,
but I wouldn't be too sure about making this generally available as-is.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/
"Oh, great altar of passive entertainment, bestow upon me thy discordant images
at such speed as to render linear thought impossible" (Calvin a la TV)



pgsql-hackers by date:

Previous
From: Antonin Houska
Date:
Subject: Re: why there is not VACUUM FULL CONCURRENTLY?
Next
From: Daniel Gustafsson
Date:
Subject: Re: Prevent an error on attaching/creating a DSM/DSA from an interrupt handler.