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 1lw2rz-0006r9-17 for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Jun 2021 13:24:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lw2ry-0003W0-0R for pgsql-bugs@arkaria.postgresql.org; Wed, 23 Jun 2021 13:24:42 +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 1lw2rx-0003Vs-Pz for pgsql-bugs@lists.postgresql.org; Wed, 23 Jun 2021 13:24:41 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lw2rv-0007Bz-QV for pgsql-bugs@lists.postgresql.org; Wed, 23 Jun 2021 13:24:40 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15NDOcWj2080224; Wed, 23 Jun 2021 09:24:39 -0400 From: Tom Lane To: Sudheer H R cc: pgsql-bugs@lists.postgresql.org Subject: Re: Found a buffer-overflow defect in asynchronous database connection API PQconnectPoll In-reply-to: <5372B6D4-8276-42C0-B8FB-BD0918826FC3@tekenlight.com> References: <5372B6D4-8276-42C0-B8FB-BD0918826FC3@tekenlight.com> Comments: In-reply-to Sudheer H R message dated "Wed, 23 Jun 2021 17:43:32 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2080222.1624454678.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 23 Jun 2021 09:24:38 -0400 Message-ID: <2080223.1624454678@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Sudheer H R writes: > While trying to sanitise the code for heap buffer overflows I compiled a= nd linked the executable with clang -fsanitize=3D=E2=80=9Caddress=E2=80=9D= option. The connection library indicates a buffer over flow in an interna= l source code of the module. Hm, interesting. Our code is expecting that gss_display_status() returns a null-terminated string, but this trace suggests that the string is not necessarily null-terminated. The documentation I found on the net is unclear on the point, and the code I could find is split as to how the string is treated. If it's not supposed to be null-terminated, we're hardly the only ones making that mistake. In any case, you wouldn't get here unless we'd run into some kind of problem trying to make a GSS connection. Could you maybe explain the conditions you're running this under, and/or print out the failure message it constructs? regards, tom lane