Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1usa4w-007VkW-Qa for pgsql-bugs@arkaria.postgresql.org; Sun, 31 Aug 2025 04:54:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1usa4u-000Yfs-E2 for pgsql-bugs@arkaria.postgresql.org; Sun, 31 Aug 2025 04:54:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1usa4t-000Yfj-L7 for pgsql-bugs@lists.postgresql.org; Sun, 31 Aug 2025 04:54:08 +0000 Received: from fout-b5-smtp.messagingengine.com ([202.12.124.148]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1usa4r-002mFB-0P for pgsql-bugs@lists.postgresql.org; Sun, 31 Aug 2025 04:54:07 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id 912951D0006E; Sun, 31 Aug 2025 00:54:01 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Sun, 31 Aug 2025 00:54:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1756616041; x=1756702441; bh=C5XHmhEvHN lnqbangOnof8DAQcv/9r7y5+tO4fHFiI4=; b=m+2Ns3B4d0Yzi8P4994sF43zLO S7vWd/UzW+DBhijM4Q4iduXhOnO22V+l+b/lboW4bciczqHUOv8mtAOXEJUFpH7x IeVsixz3uY5mgxGbKhl5YttEAv3Jm594WnR49Hd14IGTxEZ5xHyIqWMvO3RYT1v1 6CpEw4CyTgrhGBtGFH8jQAUERzXNVtcEEDJTo1fZEOc2iuEan0ysvebJ+L+pPB72 C33S1J5/68sGr/9+82DPjy5/fQwGrHVcRgbcA9Hiyxdo9yrbhFs7tT1w7hGNoL6u jQ+YlOJIrhh9FJgsZ+ld7EksmWUaErRPc7B4NaL2wRBSXAaf5RTp3+qoqK3Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1756616041; x=1756702441; bh=C5XHmhEvHNlnqbangOnof8DAQcv/9r7y5+t O4fHFiI4=; b=VHMVMj5TAZn79LddUQwHwqFmZJJW0VyyoSNiTFk0n6cToXxNiW6 SGnhgBKpjcxNh1HCWARiaYfIgZvM1v0ostrSyHRyeGZMqPp4q3W0NSTsVrjwMvs1 Y+7pNVGT+I2fxEb63/k9WHzb1MO1cCGM4uNmDnU4UjlhEtWERsmSVw4SFH/S2UQy l5NrhbXpNkKcuF/1FTsCYXIKtZdJaAPEV9G14e9fmhPSxLvzmRexfxrmi29Z/KqS mYYH9AV4iZyBvk39+Vcy83S+xP5guX/wmAblfflWx5f/+KqsX21xGPj2KQEuiLaN ljvcX6fJOQRwxhkfR2wurRmPSqhZGZBJUFw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddukeekfeeiucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucgfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvve fukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhi vghruceomhhitghhrggvlhesphgrqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnh epteelieefudffhffhtdetleeggeegfffhkeeuveetiefgudduvedutefggeeivdejnecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrg gvlhesphgrqhhuihgvrhdrgiihiidpnhgspghrtghpthhtohepvddpmhhouggvpehsmhht phhouhhtpdhrtghpthhtoheprhgrnhesuhhnuhhsvgguvhgrrhdrtghomhdprhgtphhtth hopehpghhsqhhlqdgsuhhgsheslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 31 Aug 2025 00:53:59 -0400 (EDT) Date: Sun, 31 Aug 2025 13:53:50 +0900 From: Michael Paquier To: Ran Benita Cc: pgsql-bugs@lists.postgresql.org Subject: Re: Broken PQtrace CopyData display Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="myiSA0NbygZOH+8n" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --myiSA0NbygZOH+8n Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 29, 2025 at 10:45:18PM +0300, Ran Benita wrote: > I used PQtrace to trace a logical decoding session, and was confused to s= ee > lines like this: >=20 > 2025-08-29 22:09:57.633980 F 38 CopyData 'r\x00\x00\x00\x00\xffffff8e\x0= 7\xffffff85x\x00\x00\x00\x00\xffffff8e\x07\xffffff85x\x00\x00\x00\x00\x00\x= 00\x00\x00\x00\x02\xffffffe0\xffffff84\xffffff89R\xffffffd7\xffffffb8\x00' >=20 > The data doesn't make sense and has the wrong length. A quick look shows = that > the \xffffff85 parts are a signedness issue (on my compiler char is signe= d). > > @@ -212,7 +212,7 @@ pqTraceOutputNchar(FILE *pfdebug, int len, const char= *data, int *cursor, bool s > else > { > fwrite(v + next, 1, i - next, pfdebug); > - fprintf(pfdebug, "\\x%02x", v[i]); > + fprintf(pfdebug, "\\x%02x", (unsigned char) v[i]); > next =3D i + 1; > } > } Yeah. Not a lot of people use the libpq tracing, but it would be better to show non-printable data in a consistent way. > The diff below fixes this particular problem, though they say bugs are li= ke > mushrooms, if you find one then there are probably others nearby, so a mo= re > comprehensive fix may be warranted. There's one more mushroom: pqTraceOutputByte1() also uses a %02X without a cast for non-printable data. Note as well logicalmsg_desc(), auth-oauth.c, mbprint.c (which uses an unsigned char type in input to force things). -- Michael --myiSA0NbygZOH+8n Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmiz1V4ACgkQnvQgOdby QH3j9w/8DtzzHovcsN6AM67cWx1V2tyoD5GY+JLmOqV+lyg7rSu8i1Ip0nE4ZzZu YwpUpQ+FWWYN704We3U+28e/DwIdz1iGScVh7EJsgV5RJTs/C8yMFKHEHcRDzN+6 MvKwSYjeCeNPcMEOYfe7B/Qcf9Y6BV1XTjHmlKCq6tMAHpZ4rjtuGSHZgVCsDp6o Sxf7Ipa6Wtimxx3H2IjaDBKwKg2yKRPk0D+3rYx+KG4Jo+shq0oY+UT3yJD3JZ7j 63h4wG9OrhGxeh7krzIuYvmUFtTgbECwz3EHCdBw5//rqoJ7JC+zdZF7eoioW81P soT5P4+wkD6o2v4QikFVU0iqUPkrEaKpsvLxMjMnkGrbVYh3Gb2skrwdup4S+2AO NyTAKWLadCkb8jUCO8NFGAi0SQH3Q6LJI73vBCQkvmL8HhyuhUqJlgeFaKTq86eT 6EcqdfQw5aewnrby88YbvUcr91+r9SI5ibDL50g85wKzh1P3KjZurrYCPtweIVw9 x2e1RlQzg8Wwbh2Gdop6RG09TCmHiwEUX20sFEF2oxOCVRvoCqvnJ0QZFwHXjpBx /PWf4VX9+U2TPTMiDwTwj/daYVlN0K49gpSynVR/RVCBkzG97sq14Muy6w5ZhWwP X+z2ysqN/emMxIMqG9wQc9lfKejMkiiGf5PFAMb1uca+3xs6sGE= =z8C8 -----END PGP SIGNATURE----- --myiSA0NbygZOH+8n--