Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f5bd5a1

Browse files
author
Commitfest Bot
committed
[CF 5741] v1 - Fix hostaddr crash during non-blocking cancellation
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5741 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/CAOYmi+mQCHUm5uQ3ThBv0g42wyNt4OSAmM8r2V7YwuAf5bm5vA@mail.gmail.com Author(s): Jacob Champion
2 parents 4fbb46f + c94ebd4 commit f5bd5a1

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

.cirrus.tasks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ env:
2929
MTEST_ARGS: --print-errorlogs --no-rebuild -C build
3030
PGCTLTIMEOUT: 120 # avoids spurious failures during parallel tests
3131
TEMP_CONFIG: ${CIRRUS_WORKING_DIR}/src/tools/ci/pg_ci_base.conf
32-
PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth
32+
PG_TEST_EXTRA: kerberos ldap ssl libpq_encryption load_balance oauth tcp
3333

3434

3535
# What files to preserve in case tests fail

src/interfaces/libpq/fe-cancel.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ PQcancelCreate(PGconn *conn)
137137
goto oom_error;
138138

139139
originalHost = conn->connhost[conn->whichhost];
140+
cancelConn->connhost[0].type = originalHost.type;
141+
140142
if (originalHost.host)
141143
{
142144
cancelConn->connhost[0].host = strdup(originalHost.host);

src/test/modules/libpq_pipeline/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ tests += {
2626
'tap': {
2727
'tests': [
2828
't/001_libpq_pipeline.pl',
29+
't/002_tcp.pl',
2930
],
3031
'deps': [libpq_pipeline],
3132
},
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
# Copyright (c) 2021-2025, PostgreSQL Global Development Group
3+
4+
use strict;
5+
use warnings FATAL => 'all';
6+
7+
use PostgreSQL::Test::Utils;
8+
use Test::More;
9+
10+
# Force test nodes to begin in TCP mode.
11+
# Use an INIT block so it runs after the BEGIN block in Utils.pm.
12+
13+
INIT { $PostgreSQL::Test::Utils::use_unix_sockets = 0; }
14+
15+
use PostgreSQL::Test::Cluster;
16+
17+
if (!$ENV{PG_TEST_EXTRA} || $ENV{PG_TEST_EXTRA} !~ /\btcp\b/)
18+
{
19+
plan skip_all =>
20+
'Potentially unsafe test TCP not enabled in PG_TEST_EXTRA';
21+
}
22+
23+
my $node = PostgreSQL::Test::Cluster->new('main');
24+
$node->init;
25+
$node->start;
26+
27+
# Don't let PGHOST interfere with these tests.
28+
delete $ENV{PGHOST};
29+
30+
my @cases = (
31+
$node->connstr('postgres') . " max_protocol_version=latest",
32+
$node->connstr('postgres') . " max_protocol_version=3.0",
33+
"hostaddr=127.0.0.1 port=" . $node->port);
34+
35+
foreach my $c (@cases)
36+
{
37+
# Don't use $node->command_ok(); it overrides PGHOST too.
38+
command_ok(
39+
[ 'libpq_pipeline', 'cancel', $c ],
40+
"libpq_pipeline cancel, connstr: " . $c);
41+
}
42+
43+
$node->stop('fast');
44+
45+
done_testing();

0 commit comments

Comments
 (0)