Re: issue in pgfdw_report_error()?

From: Fujii Masao <masao(dot)fujii(at)oss(dot)nttdata(dot)com>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: issue in pgfdw_report_error()?
Date: 2021-11-19 15:18:15
Message-ID: 41aae5d4-4d11-85f6-8f32-1bb5349ce959@oss.nttdata.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2021/11/19 21:57, Bharath Rupireddy wrote:
>> If this is a bug, IMO the following change needs to be applied. Thought?
>>
>> -------------------
>> ereport(elevel,
>> (errcode(sqlstate),
>> - message_primary ? errmsg_internal("%s", message_primary) :
>> + (message_primary != NULL && message_primary[0] != '\0') ?
>> + errmsg_internal("%s", message_primary) :
>> errmsg("could not obtain message string for remote error"),
>> -------------------

I attached the patch.

> What if conn->errorMessage.data is NULL and PQerrorMessage returns it?
> The message_primary can still be NULL right?

Since conn->errorMessage is initialized by initPQExpBuffer(),
PQerrorMessage() seems not to return NULL. But *if* it returns NULL,
pchomp(NULL) is executed and would cause a segmentation fault.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION

Attachment Content-Type Size
pgfdw_report_error_v1.patch text/plain 690 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2021-11-19 15:18:55 Re: Frontend error logging style
Previous Message Dinesh Chemuduru 2021-11-19 15:16:29 Re: Pasword expiration warning