From 7363d50a1e284d64f5b347ada036174e4fecaa3c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 1 Dec 2014 22:25:18 +0100 Subject: [PATCH] output/httpd/IcyMetaDataServer: use CopyString() instead of g_strlcpy() --- configure.ac | 2 -- .../plugins/httpd/IcyMetaDataServer.cxx | 25 ++++++------------- 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index 58dc6dcd7..a539731f8 100644 --- a/configure.ac +++ b/configure.ac @@ -348,8 +348,6 @@ AC_ARG_ENABLE(httpd-output, AS_HELP_STRING([--enable-httpd-output], [enables the HTTP server output]),, [enable_httpd_output=auto]) -MPD_DEPENDS([enable_httpd_output], [enable_glib], - [Cannot use --enable-httpd-output with --disable-glib]) AC_ARG_ENABLE(inotify, AS_HELP_STRING([--disable-inotify], diff --git a/src/output/plugins/httpd/IcyMetaDataServer.cxx b/src/output/plugins/httpd/IcyMetaDataServer.cxx index 5f68ff982..108d4e7ec 100644 --- a/src/output/plugins/httpd/IcyMetaDataServer.cxx +++ b/src/output/plugins/httpd/IcyMetaDataServer.cxx @@ -22,8 +22,8 @@ #include "Page.hxx" #include "tag/Tag.hxx" #include "util/FormatString.hxx" - -#include +#include "util/StringUtil.hxx" +#include "util/Macros.hxx" #include @@ -95,25 +95,14 @@ icy_server_metadata_page(const Tag &tag, const TagType *types) // Length + Metadata - "StreamTitle='';StreamUrl='';" = 4081 - 28 char stream_title[(1 + 255 - 28) * 16]; + char *p = stream_title, *const end = stream_title + ARRAY_SIZE(stream_title); stream_title[0] = '\0'; - unsigned position = 0; - while (position < sizeof(stream_title) && item <= last_item) { - size_t length = 0; + while (p < end && item <= last_item) { + p = CopyString(p, tag_items[item++], end - p); - length = g_strlcpy(stream_title + position, - tag_items[item++], - sizeof(stream_title) - position); - - position += length; - - if (item <= last_item) { - length = g_strlcpy(stream_title + position, - " - ", - sizeof(stream_title) - position); - - position += length; - } + if (item <= last_item) + p = CopyString(p, " - ", end - p); } char *icy_string = icy_server_metadata_string(stream_title, "");