-
Notifications
You must be signed in to change notification settings - Fork 463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix FIFO on Windows not working with Windows linebreaks #9657
Conversation
Necessary for #9493. (Well, probably not strictly, but it would require additional changes. From what I can tell, the |
src/engine/shared/fifo.cpp
Outdated
pBuf[i] = '\0'; | ||
continue; | ||
} | ||
else if(pBuf[i] != '\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we could simply treat \r
and \n
the same, i.e. both as line endings? As I understand it, this PR would ignore everything between \r
and \n
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then there are lots of empty lines on Windows. We should probably check that it's actually \r\n or \n\r and only then ignore them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it to be consistent with the behavior of CLineReader
so only \n
and \r\n
will be considered as line breaks. Stray \r
are not considered line breaks.
ddnet/src/engine/shared/linereader.cpp
Lines 59 to 74 in 85a30b6
if(m_pBuffer[m_BufferPos] == '\0' || m_pBuffer[m_BufferPos] == '\n' || (m_pBuffer[m_BufferPos] == '\r' && m_pBuffer[m_BufferPos + 1] == '\n')) | |
{ | |
if(m_pBuffer[m_BufferPos] == '\0') | |
{ | |
m_ReadLastLine = true; | |
} | |
else | |
{ | |
if(m_pBuffer[m_BufferPos] == '\r') | |
{ | |
m_pBuffer[m_BufferPos] = '\0'; | |
++m_BufferPos; | |
} | |
m_pBuffer[m_BufferPos] = '\0'; | |
++m_BufferPos; | |
} |
Carriage return `\r` characters were not properly ignored in Windows' FIFO implementation (named pipes), leading to incorrect commands being executed (including a trailing `\r`) which was causing some commands like rcon authentication and map changes to fail due to incorrect password/filename unless the arguments were escaped with quotes.
69b3f0d
to
f500600
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Carriage return
\r
characters were not properly ignored in Windows' FIFO implementation (named pipes), leading to incorrect commands being executed (including a trailing\r
) which was causing some commands like rcon authentication and map changes to fail due to incorrect password/filename unless the arguments were escaped with quotes.Checklist