diff options
| author | 0xd34df00d <0xd34df00d@gmail.com> | 2019-10-12 18:42:32 -0400 |
|---|---|---|
| committer | LNJ <lnj@kaidan.im> | 2019-10-14 22:09:40 +0200 |
| commit | daa03c8e12666e7ec47da7ef38770642282b3c75 (patch) | |
| tree | aba51026ee9ea71d9ef4e6d9da85a4da44b761d8 /src/client/QXmppOutgoingClient.cpp | |
| parent | e52030614d935dfb044b0e3fc57a30d812d626f3 (diff) | |
Fix potential SEGFAULT on connection error
`socketError()` calls `connectToNextDNSHost()` which might cause
`socketError()` synchronously (and recursively), thus not giving a
change for updating `nextSrvRecordIdx`.
Overall, this results in attempting to connect to the same DNS record
recursively, until the stack is exhausted, resulting in SEGFAULT.
One of the solutions (done in this commit) is to increment the record
index _before_ attempting to connect.
Diffstat (limited to 'src/client/QXmppOutgoingClient.cpp')
| -rw-r--r-- | src/client/QXmppOutgoingClient.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/client/QXmppOutgoingClient.cpp b/src/client/QXmppOutgoingClient.cpp index 1fcb7c28..b9f01188 100644 --- a/src/client/QXmppOutgoingClient.cpp +++ b/src/client/QXmppOutgoingClient.cpp @@ -165,11 +165,10 @@ void QXmppOutgoingClientPrivate::connectToHost(const QString &host, quint16 port void QXmppOutgoingClientPrivate::connectToNextDNSHost() { + auto curIdx = nextSrvRecordIdx++; connectToHost( - dns.serviceRecords().at(nextSrvRecordIdx).target(), - dns.serviceRecords().at(nextSrvRecordIdx).port()); - - nextSrvRecordIdx++; + dns.serviceRecords().at(curIdx).target(), + dns.serviceRecords().at(curIdx).port()); } /// Constructs an outgoing client stream. |
