Commit a73195b7 authored by Max Kellermann's avatar Max Kellermann

output/httpd/IcyMetaDataServer: pad the string with 15 spaces

Fixes a buffer overflow due to the bad formula rounding the buffer size up. At the same time, remove the "+1" from the meta_length calculation, which takes the padding into account and at the same time implements proper rounding.
parent 1bd00b8a
...@@ -60,7 +60,11 @@ icy_server_metadata_string(const char *stream_title, const char* stream_url) ...@@ -60,7 +60,11 @@ icy_server_metadata_string(const char *stream_title, const char* stream_url)
{ {
// The leading n is a placeholder for the length information // The leading n is a placeholder for the length information
auto icy_metadata = FormatString("nStreamTitle='%s';" auto icy_metadata = FormatString("nStreamTitle='%s';"
"StreamUrl='%s';", "StreamUrl='%s';"
/* pad 15 spaces just in case
the length needs to be
rounded up */
" ",
stream_title, stream_title,
stream_url); stream_url);
...@@ -68,7 +72,7 @@ icy_server_metadata_string(const char *stream_title, const char* stream_url) ...@@ -68,7 +72,7 @@ icy_server_metadata_string(const char *stream_title, const char* stream_url)
meta_length--; // subtract placeholder meta_length--; // subtract placeholder
meta_length = meta_length / 16 + 1; meta_length = meta_length / 16;
icy_metadata[0] = meta_length; icy_metadata[0] = meta_length;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment