-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
When the length of the log content of the 'srs_error' level exceeds 4096, it will cause a memory overflow, leading to a stack corruption and a crash. #1229
Comments
Can you help submit a Pull Request? Please make sure to maintain the markdown structure.
|
I checked the manual:
The single test program is as follows:
This risk has been resolved at 78da67e. There may be security risks with sprintf and vsprintf due to the lack of string length restrictions.
SRS is mainly used in HDS and has been fixed at ad70589. It is also used in JSON and appears to have no risks. Thank you @dean-river 👍
|
The code is as follows:
Due to vsnprintf, when the content to be written is greater than LOG_MAX_SIZE - size, its return value is not the actual length written, but rather the length that should be written. The standard states it as follows:
So, when the content of the fmt, ap part is greater than LOG_MAX_SIZE, the size returned by vsnprintf will also be greater than LOG_MAX_SIZE. Therefore, the subsequent snprintf will cause a memory overflow and corrupt the stack. It is recommended to place the content to be written by snprintf before vsnprintf.
TRANS_BY_GPT3
The text was updated successfully, but these errors were encountered: