mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-04 09:43:08 +02:00
Fix segfault on delayed connection errors.
Connection errors could cause a segfault if the error was delayed enough to pass the initial call to sckClientOpenWait() and the error was instead thrown by a subsequent call to sckClientOpenWait(), which was not correctly initializing a variable required for error handling. While this can be produced fairly easily in a test environment, I was unable to craft a unit test to hit this exact condition, probably due to timing. The new code still has full coverage and I added several comments to help prevent regressions.
This commit is contained in:
parent
04ef43d9ed
commit
60f96429b8
@ -14,6 +14,19 @@
|
||||
<p>Fix permissions when <cmd>restore</cmd> run as root user.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<github-issue id="2420"/>
|
||||
<github-pull-request id="2422"/>
|
||||
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="anton.glushakov"/>
|
||||
<release-item-contributor id="david.steele"/>
|
||||
<release-item-reviewer id="david.christensen"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Fix segfault on delayed connection errors.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<github-issue id="2418"/>
|
||||
<github-pull-request id="2421"/>
|
||||
|
@ -159,10 +159,17 @@ sckClientOpen(THIS_VOID)
|
||||
{
|
||||
SckClientOpenData *const openDataWait = lstGet(openDataList, openDataIdx);
|
||||
|
||||
if (openDataWait->fd != 0 && sckClientOpenWait(openDataWait, 0))
|
||||
if (openDataWait->fd != 0)
|
||||
{
|
||||
// Set so the connection will be closed on error
|
||||
openData = openDataWait;
|
||||
break;
|
||||
|
||||
// Check if the connection has completed without waiting
|
||||
if (sckClientOpenWait(openData, 0))
|
||||
break;
|
||||
|
||||
// Reset to NULL if the connection is still waiting so another connection can be attempted
|
||||
openData = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -233,6 +240,8 @@ sckClientOpen(THIS_VOID)
|
||||
}
|
||||
CATCH_ANY()
|
||||
{
|
||||
ASSERT(openData != NULL);
|
||||
|
||||
// Close socket
|
||||
close(openData->fd);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user