1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1229: Check the return value of vsnprintf.

This commit is contained in:
winlin 2022-08-08 08:22:02 +08:00
parent 079ac107f0
commit 5ae495ab95
4 changed files with 94 additions and 32 deletions

View file

@ -49,7 +49,7 @@ public:
{
static char buf[4096] = {0};
int nbytes = vsnprintf(buf, sizeof(buf), fmt, vl);
if (nbytes > 0) {
if (nbytes > 0 && nbytes < sizeof(buf)) {
// Srs log is always start with new line, replcae '\n' to '\0', make log easy to read.
if (buf[nbytes - 1] == '\n') {
buf[nbytes - 1] = '\0';