-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
By submitting this bug issue, you agree to the following.
- This is a bug in the software that resides in this repository, and not a support matter (use https://otland.net/forums/support.16/ for support)
- This issue is reproducible without changes to the C++ code in this repository
- This bug has not been resolved in master branch
- There is no existing issue for this bug already
Does this bug crash tfs?
yes
Server Version
1.7 (Master)
Operation System
all (listed below)
OS Description
No response
Bug description
Possible getConnection() null reference exception
Possible Pull Requests which are to blame
- [https://github.com/Minimal HTTP login server #4706] Minimal HTTP login server #4706
Steps to reproduce
- Compile
- Login
- Pray
Actual Behavior
Works for the most part, rare race condition could result in a null reference exception and crash the server.
void ProtocolLogin::onRecvFirstMessage(NetworkMessage& msg) checks if the connection exists auto connection = getConnection(); and then schedules a Task for getCharacterList()
PR #4709 for the HTTP Login server adds reference to getConnection()->getIP().to_string() without first checking if getConnection() returns a valid ptr
This line here:
forgottenserver/src/protocollogin.cpp
Line 121 in 1c68163
| db.escapeString(getConnection()->getIP().to_string())))) { |
Just like in onRecvFirstMessage(), if it's going to reference it, it should check again since the function is scheduled to run later, even if it's within nano seconds.
Expected Behavior
If you're going to use/reference the connection, make sure it exists first like it does from ProtocolLogin::onRecvFirstMessage
auto connection = getConnection();
if (!connection) {
return;
}
https://github.com/otland/forgottenserver/blob/master/src/protocollogin.cpp#L236
Metadata
Metadata
Assignees
Labels
Type
Projects
Status