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 1vAemn-004ePs-87 for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Oct 2025 01:34:08 +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 1vAemm-00DQFg-7g for pgsql-hackers@arkaria.postgresql.org; Mon, 20 Oct 2025 01:34:07 +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 1vAeml-00DQFN-Ud for pgsql-hackers@lists.postgresql.org; Mon, 20 Oct 2025 01:34:06 +0000 Received: from mail-ot1-x332.google.com ([2607:f8b0:4864:20::332]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vAemj-002hc2-1G for pgsql-hackers@postgresql.org; Mon, 20 Oct 2025 01:34:06 +0000 Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-7c27e5ca2beso966410a34.3 for ; Sun, 19 Oct 2025 18:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760924045; x=1761528845; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=if6UtMgW4UYcCWRX91fe3Dak3vpoKO2ForR3oUuiZkM=; b=VCONkbR6JXOP6WADN38V0l9fTsseBZEzsocHfYkLc8PufGLFEdWPYeI6bv7EuSTAjw +u5SA9+IC99DWoFuceTaIoc/V4sTWxBL9Q/feX9NsQeee4wN06Nk4/iiMIz6cMLnWRLy O+nfnCmegnHB66xqo7QxQsOJbDfV/RMfDjvBzJO3wQcXiygdrbBTsQhgHQP4lHKi+p7w DXCW1wiWEoT5GdNO6yuXwIc8/tplLj4gHo3QFvhH9KbTPBVXPU6X0O/Gb4rZUjc6tXBD GPXD2NPjUnPuv8e2cKB5b3h6FZGedjGOi9TwxO5qmC5LZ5TcFbIO2+UiCOOfEfpCnESm A6CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760924045; x=1761528845; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=if6UtMgW4UYcCWRX91fe3Dak3vpoKO2ForR3oUuiZkM=; b=X52SYKjaJizHOO9MPSKg4uTpF1dNPPVThvueRD8v0+4jjTVyCziGAA0cla9hByxQ2p +vTGnWxsc7Z25N/C4nJ62+r1rX1HdLKB+ICalS1yNHqZ2hO9wcIdYKB9uUeRb5RtMtGU 2RQGWqTfk4mTFmknO2WSfcRd4q3I53DfdByI/wI8W3ZWxBXw3pn+TfflZntTnF18Ay48 V5zD0pXZbFerJB9W8jJyqqsDgS+gPVXKMxLamIEdBIO+ekQdw0W+RrrOaNjVfFTSrUer GShrayGd2tbl6aAwahFEWAL4U5wyj4lJYMDyG8GR47FikFqamEPxV5VfOzmtRp+/OuRR 2+eA== X-Gm-Message-State: AOJu0YzJnMEr8xXgnNtE+npoVsZ4MKKjWrZou3PWfRegXqjmXdCzI9ZY bi/lR223bQnBc261sRNdyYPJQy0abA+mtgo/T8olcycrv4+o/KcL+ivvLkcELh+Lobc= X-Gm-Gg: ASbGncvp0/Md9ZcqGABY9uMVy1zQH+ugg0s4rOaF022AQwcjpcdenzZbrnyxbn6biFG RNRdXAIJXlHYcHawG8emM26Oxn+TtnqDED98kPhuYrRx+Z4WTGlsdvubILQXWpo9oRO+2ySfUjB qwB3BfZY4lXpZwHh0dYFfSAz2fhdIyL/+SkqCD9ULcjp5avz0bB7DAgFHItlV1I5CRTAlreZ5Qp a3276nhh6LKP9+pG3szDPjBbeZiBRPwCQopygA5GCIn/AR3TuoA7nxgEf6UCwzeIvr0H049trlG MAbOd5bORl8bztA2TG6U6lyk9/TSyE31F3dT2rbDYJjvI4KR9JuTVVJSxrZmS+XGHhipd0BAvnx IhMxJuVCq2N7aIPcSCRtGnDTl/Rf0SmMVDi796TAbx5R29DjkNLXHZfmn0Ha5OJRcoCHmQyaJOG QgrmZSQNO4ErcwVP2/j1k= X-Google-Smtp-Source: AGHT+IGwWvl0xcBQGAuuAK6AoK6u0VUrfwgftTXDQyrhUIbm4RCaiTLK/FRL/ePLZBBfhkE3ty1gZw== X-Received: by 2002:a05:6808:4492:b0:43f:2b18:1608 with SMTP id 5614622812f47-443a2dcb631mr4986519b6e.2.1760924044737; Sun, 19 Oct 2025 18:34:04 -0700 (PDT) Received: from [172.20.6.165] ([163.116.253.145]) by smtp.gmail.com with ESMTPSA id 5614622812f47-443dc4d896asm1539478b6e.3.2025.10.19.18.34.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Oct 2025 18:34:03 -0700 (PDT) Message-ID: <604e8e01-90cb-438e-abbb-911c58399877@gmail.com> Date: Sun, 19 Oct 2025 20:34:02 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Fix POSIX compliance in pgwin32_unsetenv() To: Michael Paquier Cc: pgsql-hackers@postgresql.org References: Content-Language: en-US From: Bryan Green In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 10/19/25 20:02, Michael Paquier wrote: > On Sat, Oct 18, 2025 at 01:26:40PM -0500, Bryan Green wrote: >> I noticed that pgwin32_unsetenv() in src/port/win32env.c lacks the input >> validation that its sibling function pgwin32_setenv() has (lines 126-132). >> >> Without these checks, the function will crash on NULL input via >> strlen(NULL), and will accept empty strings or strings containing '=' in >> violation of POSIX.1-2008. >> >> The attached patch adds the same validation that pgwin32_setenv already >> does, making the two functions consistent. This is purely defensive - it >> only affects callers passing invalid arguments. > > I presume that you have tried to use this routine on some external > code on WIN32 to note that it was just crashing. > > The current state of pgwin32_unsetenv() dates back to 0154345078fb. > The POSIX checks of setenv() are more recent than that, as in > 7ca37fb0406b down to v14. I agree that the inconsistency in handling > the input arguments is annoying, so if there are no objections let's > apply the same checks down to v14 like the setenv() piece. It's > better than a hard crash. > -- > Michael I have been going through all of the windows code line by line. That is how I initially noticed this. I then wrote a program to exercise the code and confirm the crash. I agree it should be backported. BG