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

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

2010/9/28 Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com>:
> 2010/9/28 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>> =?UTF-8?Q?Grzegorz_Ja=C5=9Bkiewicz?= <gryzman(at)gmail(dot)com> writes:
>>> It would crash if input is of unrecognized format. Probably than
>>> there's going to be more problems to be concerned with, but just in
>>> case, don't crash in
>>
>> I'm not sure why you think this is a good change, but it would break
>> things: in particular, the code would fail to null-terminate the string
>> in the hex-output case.  Also, the case that you seem to be trying to
>> defend against can't happen because elog(ERROR) doesn't return.
>>
>
> ...
>                rp = result = NULL;             /* keep compiler quiet */
>        }
>        *rp = '\0';
> ....
>
> this strikes me as a clear case of possible null pointer dereference,
> wouldn't you agree ?
> I know the case is very corner-ish, but still valid imo.

That comment that says "keep compiler quiet" is there because we
expect that line of code never to get executed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2010-09-28 15:27:57 Re: small fix to possible null pointer dereference in byteaout() varlena.c
Previous Message Tom Lane 2010-09-28 15:23:35 Re: small fix to possible null pointer dereference in byteaout() varlena.c