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

Fix the snprintf size issue.

This commit is contained in:
winlin 2022-08-10 08:32:02 +08:00
parent 1ab584b2ae
commit a71eddd56a
10 changed files with 46 additions and 17 deletions

View file

@ -276,16 +276,16 @@ bool srs_check_ip_addr_valid(string ip)
string srs_int2str(int64_t value)
{
// len(max int64_t) is 20, plus one "+-."
char tmp[22];
snprintf(tmp, 22, "%" PRId64, value);
char tmp[21 + 1];
snprintf(tmp, sizeof(tmp), "%" PRId64, value);
return tmp;
}
string srs_float2str(double value)
{
// len(max int64_t) is 20, plus one "+-."
char tmp[22];
snprintf(tmp, 22, "%.2f", value);
char tmp[21 + 1];
snprintf(tmp, sizeof(tmp), "%.2f", value);
return tmp;
}