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 1tjN48-0099Xz-U3 for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Feb 2025 18:39:00 +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 1tjN46-00300u-On for pgsql-hackers@arkaria.postgresql.org; Sat, 15 Feb 2025 18:38:58 +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.94.2) (envelope-from ) id 1tjN46-00300l-F3 for pgsql-hackers@lists.postgresql.org; Sat, 15 Feb 2025 18:38:58 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tjN44-000zhN-2Q for pgsql-hackers@postgresql.org; Sat, 15 Feb 2025 18:38:57 +0000 Received: by mail-pj1-x102b.google.com with SMTP id 98e67ed59e1d1-2f441791e40so4517965a91.3 for ; Sat, 15 Feb 2025 10:38:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1739644735; x=1740249535; darn=postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=p4Hn8raDKxxqQ5IgriQ4zz4NOc9XtKGNTzIMT2xXuq0=; b=QsaSjEnltS8W6TQ8XlpY+VcATLfQ6fR7hY0S5i0n8r0GjOWSazqm4GS4RTLfcL3hpl 1A6172Y1f+09lU+l2XjG2/xLFA8l1ZEBnjFt/4Mdy6Rw4yMtqAjon8iTjnAGehnJmGuz Z9J5Ea0PPcIL7aLAnljCe4Y+VQ2Up/2ZM0tBw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739644735; x=1740249535; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=p4Hn8raDKxxqQ5IgriQ4zz4NOc9XtKGNTzIMT2xXuq0=; b=AsZZqiEnY+FUgIbQqR7iAQfQNYnj9txaIFTOZ9uFuKseIB0/0L8rOMlq4RFidB8gLk GyakxE/INP58WgxU0Z9hoNPbmjIYE21ibMRzOHmT9hCSopmdlV2l1y7d4dCeZLw+YAUn 97tqOTHvp+saUbnbUpF+5ujjU7OfBuNSCryCAR8/F4oszWTrSXWHvsxrfZfK6U+y7/vH HmWv0Zl2T9fxiCX5LVorR+6ObuEbY2AR0ROYM3uX0n7R5G507KMq//gCjMnkDYHwUSof LVT3AGhVOrbf550xigwEHcYmb4wnXtBora7Wf254SdF0bh6303lonxqx+C1t9gT//6fc svfQ== X-Forwarded-Encrypted: i=1; AJvYcCUa09UPXsI0FO/RnkhVgTXf/o4kUVyoZHzySJ6tYE4W/bt/+j4u1lQeboGCkdtbGpL/2ry3ghjkcF86UJZ3@postgresql.org X-Gm-Message-State: AOJu0YwmDK3HKlRbEJKxusPgUFmA7+pBgQh5DUdo9xtemrfVjJ6yWbLp qyHxVhLrpJ+ohdzTAuaDr6u1N/xJHzaRuA0xuzsggjjtX5oHsKBP8E0YGeP8eA== X-Gm-Gg: ASbGncvgSPzK//FumoJFWE8SS/f1jevuiw7+MChD61By0+XGj/1aS/1MPUnhs42tTOX yFX6TRHNmKANjwZTY2oqxKJKyPy1y86e/Oh+8ofvkkD0Gtzgpj1/1uoOaSnpOqHE2J8eGjUnlZx JWSvAeLgXTjaM8Y3vIii8FwxwAtu9VXp4xDAd9V7eed0LYwJNTosyK+YWU0kr8mIq1xCXTLwOa8 dSoyGq7v1nf64jcoiq35HmZlpxnHqiuaYnU6x3Bb+fojGN//K8LobNFAJl2eDJYEs1t3kNRSWNf yxMbZ9J6NQHfQL76Qg== X-Google-Smtp-Source: AGHT+IHO2AmfrYbt0/EBR1ROCd+EPNVuHl+Fr97Skb3rTTuNpVvyeiE5YPaI+Afd/L2HjiLoWDb/kw== X-Received: by 2002:a17:90b:1b46:b0:2ee:edae:780 with SMTP id 98e67ed59e1d1-2fc40f22bd3mr5934992a91.15.1739644734675; Sat, 15 Feb 2025 10:38:54 -0800 (PST) Received: from rfd.leadboat.com ([2600:1702:a20:5750::46]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2fc13ad4391sm5220969a91.27.2025.02.15.10.38.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Feb 2025 10:38:54 -0800 (PST) Date: Sat, 15 Feb 2025 10:38:52 -0800 From: Noah Misch To: Tom Lane Cc: Andres Freund , Andrew Dunstan , pgsql-hackers@postgresql.org, pgsql@j-davis.com Subject: Re: Decision by Monday: PQescapeString() vs. encoding violation Message-ID: <20250215183852.6f@rfd.leadboat.com> References: <20250215012712.45@rfd.leadboat.com> <77190.1739642883@sss.pgh.pa.us> <7vmfuavitlhjgruidll67y5cd4s3m66m4x7c4yxezkxlo4dxvv@4haeja2xdn2q> <80374.1739644510@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <80374.1739644510@sss.pgh.pa.us> User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Feb 15, 2025 at 01:23:51PM -0500, Andres Freund wrote: > On 2025-02-15 13:08:03 -0500, Tom Lane wrote: > > I studied the v3 patch a little and realized that it only fixes the > > behavior for the case of a complete-but-invalid multibyte character. > > If we have an incomplete character at the end of the string, the > > whole thing still gets dropped. Surely that's not what we want if > > we are going to adopt this behavior. Thanks for doing that. > Good catch! The different behaviour made sense when we were dropping the > entire multi-byte character, but not anymore. > > > > Here's a v4 that fixes that. As a bonus, we can get rid of > > duplicative coding since the "incomplete" and "invalid" cases > > are now treated identically. > > > One minor point is that the error messages from PQescapeStringInternal > > no longer distinguish "incomplete" from "invalid". I don't find that > > to be a terribly useful distinction, so that's fine with me. But if > > someone feels that's important to preserve, we could make it do > > something like > > I think there's some value in the distinction, because incomplete characters > can happen a lot more easily due to truncating longer strings. I don't know if > it's worth the code complexity though. While I agree it doesn't feel like a terribly-important distinction, I'd definitely keep that distinction today rather than drop it with so little notice. (I'd feel fine about dropping it in a major release. I'd probably not drop it in any minor release, but especially not this close to wrap.) On Sat, Feb 15, 2025 at 01:35:10PM -0500, Tom Lane wrote: > Andres Freund writes: > > It seems that nobody is arguing against the "just skip one byte" behaviour, so > > I'm inclined to push this fairly soon, even if Noah's "24 hours" haven't quite > > elapsed. A few more cycles in the buildfarm wouldn't hurt. Works for me; we can always revert in the event of further discussion. For what it's worth, I didn't intend this 24hr as a hard period for gating any particular action. > Agreed. I thought there would be more discussion, but it seems > nobody really objects to changing this. > > The other thing that was discussed in the security thread was > modifying PQescapeStringInternal and PQescapeInternal to produce > no more than one complaint about invalid multibyte characters, > on the grounds that input that's just plain in some other encoding > would otherwise produce a ton of repetitive messages. That seems > trivial enough to mechanize with a bool already_complained flag, > so I think we should incorporate that refinement while we're here. +1