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.96) (envelope-from ) id 1wqaie-002Ik2-1X for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Aug 2026 18:15:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wqaid-003Dgf-1F for pgsql-bugs@arkaria.postgresql.org; Sun, 02 Aug 2026 18:15:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wqaK7-0035Qc-1B for pgsql-bugs@lists.postgresql.org; Sun, 02 Aug 2026 17:50:07 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wqaK5-00000001a5q-0wc6 for pgsql-bugs@lists.postgresql.org; Sun, 02 Aug 2026 17:50:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=nZ8LPWokvxpoLIABXjg4tUmOhn2xboPpeRu2na6C0Jc=; b=4dln0p10BDPz7pkl0NH/SiyAkz UasgXSOGnF2anf/FqkGZJ/VnNML8kNpiTtcwbHvf/acyFUDWYjg9jZ3XfF5GtwwO321Bd9qSjTVM9 AvZmaYxJpCNp33TPo33Iyyt5ivXlV4qsCZAl34uXiF/QeJUqfYJjY6NFXrCykyrlx2q1o/WjEtzRs R91cZE3n3cy90k/GoskKH73qq4Z/ltIhEIVLCT64iJkhRv5bf3w4GSsRGuksRt95xcMufLbjj+0g1 iRVfJLih7CbP57jjueU4QCYK9D67y6NpZZInT3S/+jGYXSVTOrocfAPz7HRkY7EWixn3N8A11ruc0 lpMkS6oA==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wqaK4-000bBB-0f for pgsql-bugs@lists.postgresql.org; Sun, 02 Aug 2026 17:50:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1wqaK3-0000000Baln-3SEr for pgsql-bugs@lists.postgresql.org; Sun, 02 Aug 2026 17:50:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19598: pg_waldump: -s/-e accept out-of-range WAL locations and silently use the low 32 bits To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: malis@pgrust.com Reply-To: malis@pgrust.com, pgsql-bugs@lists.postgresql.org Date: Sun, 02 Aug 2026 17:49:43 +0000 Message-ID: <19598-aa67c8f4331611b4@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19598 Logged by: Michael Malis Email address: malis@pgrust.com PostgreSQL version: 18.3 Operating system: Debian Description: =20 Both LSN-accepting options parse with sscanf(optarg, "%X/%X", &xlogid, &xrecoff) into two uint32s, with no length or range check. %X converts via strtoul: a component that overflows uint32 is truncated to its low 32 bits, and one that overflows uint64 saturates and then truncates. In both cases sscanf still returns 2, so the !=3D 2 "invalid WAL location" guard never fi= res and the tool proceeds with a value the user did not ask for. PostgreSQL's own canonical LSN parser rejects the same input. Reproducer (runnable against stock PostgreSQL 18.3) --------------------------------------------------- $ pg_waldump -s 123456789/0 000000010000000000000040 pg_waldump: error: start WAL location 23456789/0 is not inside file "000000010000000000000040" Note the echoed value: the 9-hex-digit input 123456789 was silently reduced to 23456789. The saturating case: $ pg_waldump -s FFFFFFFFFFFFFFFFFFFF/0 000000010000000000000040 pg_waldump: error: start WAL location FFFFFFFF/0 is not inside file "..." Control =E2=80=94 a genuinely malformed value is rejected, so the guard wor= ks, it just never sees these inputs: $ pg_waldump -s ZZZ/0 000000010000000000000040 pg_waldump: error: invalid WAL location: "ZZZ/0" Contrast with the server's own parser on the identical string: SELECT '123456789/0'::pg_lsn; ERROR: invalid input syntax for type pg_lsn: "123456789/0" Expected vs. actual ------------------- - Expected: pg_waldump: error: invalid WAL location: "123456789/0", as for any other unparseable value. - Actual: the value is accepted, silently mangled to 23456789/0, and used. The error text the user eventually sees reports the mangled location, which actively misleads: it reads as "the location you asked for isn't in this file" when the location asked for was never used.