You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are 2 ways to fix this. This is the 2nd way:
diff --git a/src/net.c b/src/net.c
index 1fd934ce..66b4614b 100644
--- a/src/net.c
+++ b/src/net.c
@@ -1343,7 +1343,15 @@ void tputs(int z, char *s, unsigned int len)
}
#ifdef TLS
if (socklist[i].ssl) {
+
+ /* SSL_write can call ssl_info() which can call tputs() and destroy s,
+ * so lets make a copy
+ */
+ char s2[LOGLINELEN];
+ memcpy(s2, s, len);
x = SSL_write(socklist[i].ssl, s, len);
+ memcpy(s, s2, len);
+
if (x < 0) {
int err = SSL_get_error(socklist[i].ssl, x);
if (err == SSL_ERROR_WANT_WRITE || err == SSL_ERROR_WANT_READ)
Please review and tell me, which way you prefer.
The 2nd way is better because we dont remove a debug message, like we do with the 1st patch
But the 2nd way is worse, because it does 2 memcpys to achieve this.
if you dont know also, then pick the 1st way of fix, thats the PR in its current state. What i want to avoid is this PR getting stuck because of no decision on that matter.
I hunted some more.
The re-entrance issue is not really tputs(), but a chain of events like dprintf() -> dprint() -> out_dcc_general() -> escape_telnet() with the following static buffer:
Can you resolve conflicts when you get a chance? Thanks!
done.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by: https://github.com/michaelortmann/
Patch by: https://github.com/michaelortmann/
Fixes:
One-line summary:
Fix writing to tls socket
Additional description (if needed):
SSL_write()intputs()eggdrop/src/net.c
Line 1346 in 890e7e4
ssl_info()which can call
debug1():eggdrop/src/tls.c
Lines 900 to 902 in 890e7e4
which can destroy memory by a chain of events like
dprintf()->dprint()->out_dcc_general()->escape_telnet()with the following static buffer:eggdrop/src/dcc.c
Line 95 in 890e7e4
In this case, during
SSL_write(), garbage (len bytes of the debug message) will be written to the tls socket.This PR changes the
escape_telnet()function, so it doesnt use a static buffer anymore. Only pros, no cons.This bug is since at least eggdrop 1.8.3rc1, #497
Test cases demonstrating functionality (if applicable):
> openssl s_client -connect 127.0.0.1:3343Before:
After: