diff options
| author | Crystalwarrior <Varsash@Gmail.com> | 2022-07-30 19:42:22 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-30 18:42:22 +0200 |
| commit | 7b88d4be954b415e069ee0d612e4df3793c61756 (patch) | |
| tree | eb8b93c10d369c0d0c5d6629e61dc661a0863481 /src/networkmanager.cpp | |
| parent | cf91cc03f849bba498cd8d91505bf8db04f8b1f9 (diff) | |
Never send an unencoded packet to the server (#719)
* never send an unencoded packet to the server
* oops
* Improve packet validation to remove segfaults
* WARNING: commit breaks connecting to servers, need help
start fixing omniwhy caused by single fuckin string packets (AAAAAAAAAAAAAAAAA)
* Fix failed connections to servers (Thanks to @Iuvee for helping me figure this out!)
* Fix demoserver
* who the fuck still uses goto
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* ANOTHER GOTO????
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* braces
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* good bot Update src/packet_distribution.cpp
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
* Fix demoserver harder
* Improve demo logging
* Fix memory leakage by deleting the packet
Fix useless demoserver wait packet creation when none of that packet is used
Co-authored-by: stonedDiscord <Tukz@gmx.de>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Salanto <62221668+Salanto@users.noreply.github.com>
Diffstat (limited to 'src/networkmanager.cpp')
| -rw-r--r-- | src/networkmanager.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/networkmanager.cpp b/src/networkmanager.cpp index 27b3e01a..158b36b0 100644 --- a/src/networkmanager.cpp +++ b/src/networkmanager.cpp @@ -240,15 +240,29 @@ void NetworkManager::handle_server_packet(const QString& p_data) partial_packet = false; } } -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - const QStringList packet_list = in_data.split("%", QString::SkipEmptyParts); -#else + const QStringList packet_list = in_data.split("%", Qt::SkipEmptyParts); -#endif for (const QString &packet : packet_list) { - AOPacket *f_packet = new AOPacket(packet); - + QStringList f_contents; + // Packet should *always* end with # + if (packet.endsWith("#")) { + f_contents = packet.chopped(1).split("#"); + } + // But, if it somehow doesn't, we should still be able to handle it + else { + f_contents = packet.split("#"); + } + // Empty packets are suspicious! + if (f_contents.isEmpty()) { + qWarning() << "WARNING: Empty packet received from server, skipping..."; + continue; + } + // Take the first arg as the command + QString command = f_contents.takeFirst(); + // The rest is contents of the packet + AOPacket *f_packet = new AOPacket(command, f_contents); + // Ship it to the server! ao_app->server_packet_received(f_packet); } } |
