Re: [PATCH] Fix segfault calling PQflush on invalid connection

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [PATCH] Fix segfault calling PQflush on invalid connection
Дата
Msg-id 819197.1660527847@sss.pgh.pa.us
обсуждение исходный текст
Ответ на [PATCH] Fix segfault calling PQflush on invalid connection  (Daniele Varrazzo <daniele.varrazzo@gmail.com>)
Ответы Re: [PATCH] Fix segfault calling PQflush on invalid connection  (Francisco Olarte <folarte@peoplecall.com>)
Список pgsql-bugs
Daniele Varrazzo <daniele.varrazzo@gmail.com> writes:
> PQflush calls pqFlush, which performs struct access to the connection
> without checking if it's valid, resulting in a segfault if called with
> a null pointer.

> Please find attached a patch adding a guard to PQflush().

Seems reasonable, but this tickled a thought that's been in my
hindbrain for awhile: just checking for a null pointer is not
much of a check for being passed a valid PGconn pointer.  Should
we add a magic number to struct PGconn, and modify all libpq's
entry points along the lines of

    if (!conn || conn->magic != PGCONN_MAGIC)
        return failure;

I'm honestly not entirely sure if this is worth the trouble;
I've not heard of many application bugs that this would've caught.
But the lack of any such check does seem like it's not up to
modern standards.

            regards, tom lane



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Daniele Varrazzo
Дата:
Сообщение: [PATCH] Fix segfault calling PQflush on invalid connection
Следующее
От: "巨鲸"
Дата:
Сообщение: Re: BUG #17580: use pg_terminate_backend to terminate a wal sender process may wait a long time