Thread: BUG #5243: Segmentation fault when sending null to crypt();

BUG #5243: Segmentation fault when sending null to crypt();

From
"Greg Johnson"
Date:
The following bug has been logged online:

Bug reference:      5243
Logged by:          Greg Johnson
Email address:      greg.johnson@interprose.com
PostgreSQL version: 8.4.1, 8.3.8
Operating system:   CentOS 5.4
Description:        Segmentation fault when sending null to crypt();
Details:

Postgresql version 8.4.1 and 8.3.8 both seg fault when you pass null into
crypt function.

select crypt(null, gen_salt('md5'));

Server Log
----------------------------
LOG:  statement: select crypt(null, gen_salt('md5'));
LOG:  server process (PID 25855) was terminated by signal 11: Segmentation
fault
LOG:  terminating any other active server processes
FATAL:  the database system is in recovery mode
WARNING:  terminating connection because of crash of another server process
DETAIL:  The postmaster has commanded this server process to roll back the
current transaction and exit, because another server process exited
abnormally and possibly corrupted shared memory.
HINT:  In a moment you should be able to reconnect to the database and
repeat your command.

Re: BUG #5243: Segmentation fault when sending null to crypt();

From
Tom Lane
Date:
"Greg Johnson" <greg.johnson@interprose.com> writes:
> Postgresql version 8.4.1 and 8.3.8 both seg fault when you pass null into
> crypt function.

> select crypt(null, gen_salt('md5'));

Not if the crypt function is properly defined:

CREATE OR REPLACE FUNCTION crypt(text, text)
RETURNS text
AS 'MODULE_PATHNAME', 'pg_crypt'
LANGUAGE C IMMUTABLE STRICT;

The CVS history shows that the STRICT marker was added in 8.1.
If you are still using pre-8.1 definitions of the pgcrypto
functions (no doubt via a long chain of dump/reload), you really need to
update them to current, because you're missing a lot of functionality.

            regards, tom lane