Re: small fix to possible null pointer dereference in byteaout() varlena.c

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: small fix to possible null pointer dereference in byteaout() varlena.c
Date: 2010-09-28 15:23:35
Message-ID: 24913.1285687415@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

=?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= <gryzman(at)gmail(dot)com> writes:
> ...
> rp = result = NULL; /* keep compiler quiet */
> }
> *rp = '\0';
> ....

> this strikes me as a clear case of possible null pointer dereference,
> wouldn't you agree ?

No, I wouldn't. You need to enlarge your peephole by one line:

else
{
elog(ERROR, "unrecognized bytea_output setting: %d",
bytea_output);
rp = result = NULL; /* keep compiler quiet */
}
*rp = '\0';

The "keep compiler quiet" line is unreachable code (and that comment is
supposed to remind you of that).

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2010-09-28 15:24:24 Re: small fix to possible null pointer dereference in byteaout() varlena.c
Previous Message Robert Haas 2010-09-28 15:23:32 Re: security label support, revised