diff options
author | Max Kellermann <max@musicpd.org> | 2017-02-19 19:06:48 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-02-19 19:27:37 +0100 |
commit | a73195b7cc7333a1761902a56952f5f3b9832810 (patch) | |
tree | eb121816cce1dbc5e4f6250c5c2599603d4c6659 /src/output | |
parent | 1bd00b8a9ab59982ec80a598dba3aa2eb3ef03a2 (diff) |
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.
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/plugins/httpd/IcyMetaDataServer.cxx | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/output/plugins/httpd/IcyMetaDataServer.cxx b/src/output/plugins/httpd/IcyMetaDataServer.cxx index 265305cf6..fbcd07054 100644 --- a/src/output/plugins/httpd/IcyMetaDataServer.cxx +++ b/src/output/plugins/httpd/IcyMetaDataServer.cxx @@ -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 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_url); @@ -68,7 +72,7 @@ icy_server_metadata_string(const char *stream_title, const char* stream_url) meta_length--; // subtract placeholder - meta_length = meta_length / 16 + 1; + meta_length = meta_length / 16; icy_metadata[0] = meta_length; |