Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mo5ei-0004ot-Vi for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Nov 2021 15:18:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mo5eh-0004ja-SP for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Nov 2021 15:18:23 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mo5eh-0004jR-J5 for pgsql-hackers@lists.postgresql.org; Fri, 19 Nov 2021 15:18:23 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mo5ee-0001qU-IU for pgsql-hackers@lists.postgresql.org; Fri, 19 Nov 2021 15:18:22 +0000 Received: from [192.168.11.7] (p2638163-ipngn12701funabasi.chiba.ocn.ne.jp [180.59.132.163]) by oss.nttdata.com (Postfix) with ESMTPSA id 53F7D611F3; Sat, 20 Nov 2021 00:18:16 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.4 at oss.nttdata.com Content-Type: multipart/mixed; boundary="------------TWermIl7q1sRpe1ScW2UtK8g" Message-ID: <41aae5d4-4d11-85f6-8f32-1bb5349ce959@oss.nttdata.com> Date: Sat, 20 Nov 2021 00:18:15 +0900 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: issue in pgfdw_report_error()? Content-Language: en-US To: Bharath Rupireddy Cc: PostgreSQL Hackers References: <477c16c8-7ea4-20fc-38d5-ed3a77ed616c@oss.nttdata.com> From: Fujii Masao In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------TWermIl7q1sRpe1ScW2UtK8g Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 --------------TWermIl7q1sRpe1ScW2UtK8g Content-Type: text/plain; charset=UTF-8; name="pgfdw_report_error_v1.patch" Content-Disposition: attachment; filename="pgfdw_report_error_v1.patch" Content-Transfer-Encoding: base64 ZGlmZiAtLWdpdCBhL2NvbnRyaWIvcG9zdGdyZXNfZmR3L2Nvbm5lY3Rpb24uYyBiL2NvbnRy aWIvcG9zdGdyZXNfZmR3L2Nvbm5lY3Rpb24uYwppbmRleCA0YWZmMzE1YjdjLi41YzAxMzcy MjBhIDEwMDY0NAotLS0gYS9jb250cmliL3Bvc3RncmVzX2Zkdy9jb25uZWN0aW9uLmMKKysr IGIvY29udHJpYi9wb3N0Z3Jlc19mZHcvY29ubmVjdGlvbi5jCkBAIC04MjQsNyArODI0LDgg QEAgcGdmZHdfcmVwb3J0X2Vycm9yKGludCBlbGV2ZWwsIFBHcmVzdWx0ICpyZXMsIFBHY29u biAqY29ubiwKIAogCQllcmVwb3J0KGVsZXZlbCwKIAkJCQkoZXJyY29kZShzcWxzdGF0ZSks Ci0JCQkJIG1lc3NhZ2VfcHJpbWFyeSA/IGVycm1zZ19pbnRlcm5hbCgiJXMiLCBtZXNzYWdl X3ByaW1hcnkpIDoKKwkJCQkgKG1lc3NhZ2VfcHJpbWFyeSAhPSBOVUxMICYmIG1lc3NhZ2Vf cHJpbWFyeVswXSAhPSAnXDAnKSA/CisJCQkJIGVycm1zZ19pbnRlcm5hbCgiJXMiLCBtZXNz YWdlX3ByaW1hcnkpIDoKIAkJCQkgZXJybXNnKCJjb3VsZCBub3Qgb2J0YWluIG1lc3NhZ2Ug c3RyaW5nIGZvciByZW1vdGUgZXJyb3IiKSwKIAkJCQkgbWVzc2FnZV9kZXRhaWwgPyBlcnJk ZXRhaWxfaW50ZXJuYWwoIiVzIiwgbWVzc2FnZV9kZXRhaWwpIDogMCwKIAkJCQkgbWVzc2Fn ZV9oaW50ID8gZXJyaGludCgiJXMiLCBtZXNzYWdlX2hpbnQpIDogMCwK --------------TWermIl7q1sRpe1ScW2UtK8g--