pg_regress/pg_isolation_regress: Fix possible nullptr dereference.

Started by Xing Guoover 3 years ago2 messageshackers
Jump to latest
#1Xing Guo
higuoxing@gmail.com

Hi hackers,

While playing with pg_regress and pg_isolation_regress, I noticed that
there's a potential nullptr deference in both of them.

How to reproduce:

Specify the `--dbname=` option without providing any database name.

<path>/<to>/pg_regress --dbname= foo
<path>/<to>/pg_isolation_regress --dbname= foo

Patch is attached.

--
Best Regards,
Xing

Attachments:

patch.difftext/plain; charset=US-ASCII; name=patch.diffDownload+2-2
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Xing Guo (#1)
Re: pg_regress/pg_isolation_regress: Fix possible nullptr dereference.

Xing Guo <higuoxing@gmail.com> writes:

While playing with pg_regress and pg_isolation_regress, I noticed that
there's a potential nullptr deference in both of them.
How to reproduce:
Specify the `--dbname=` option without providing any database name.

Hmm, yeah, I see that too.

Patch is attached.

This patch seems like a band-aid, though. The reason nobody's
noticed this for decades is that it doesn't make a lot of sense
to allow tests to run in your default database: the odds of them
screwing up something valuable are high, and the odds that they'll
fail if started in a nonempty database are even higher.

I think the right answer is to treat it as an error if we end up
with an empty dblist (or even a zero-length name).

regards, tom lane