diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx index 5c202973f..bd2fff86a 100644 --- a/src/input/plugins/CurlInputPlugin.cxx +++ b/src/input/plugins/CurlInputPlugin.cxx @@ -433,8 +433,8 @@ CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond) static InputStream * input_curl_open(const char *url, Mutex &mutex, Cond &cond) { - if (memcmp(url, "http://", 7) != 0 && - memcmp(url, "https://", 8) != 0) + if (strncmp(url, "http://", 7) != 0 && + strncmp(url, "https://", 8) != 0) return nullptr; return CurlInputStream::Open(url, mutex, cond); diff --git a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx index 1ad7717eb..d4cd19534 100644 --- a/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx +++ b/src/playlist/plugins/SoundCloudPlaylistPlugin.cxx @@ -274,31 +274,31 @@ try { static SongEnumerator * soundcloud_open_uri(const char *uri, Mutex &mutex, Cond &cond) { - assert(memcmp(uri, "soundcloud://", 13) == 0); + assert(strncmp(uri, "soundcloud://", 13) == 0); uri += 13; char *u = nullptr; - if (memcmp(uri, "track/", 6) == 0) { + if (strncmp(uri, "track/", 6) == 0) { const char *rest = uri + 6; u = xstrcatdup("https://api.soundcloud.com/tracks/", rest, ".json?client_id=", soundcloud_config.apikey.c_str()); - } else if (memcmp(uri, "playlist/", 9) == 0) { + } else if (strncmp(uri, "playlist/", 9) == 0) { const char *rest = uri + 9; u = xstrcatdup("https://api.soundcloud.com/playlists/", rest, ".json?client_id=", soundcloud_config.apikey.c_str()); - } else if (memcmp(uri, "user/", 5) == 0) { + } else if (strncmp(uri, "user/", 5) == 0) { const char *rest = uri + 5; u = xstrcatdup("https://api.soundcloud.com/users/", rest, "/tracks.json?client_id=", soundcloud_config.apikey.c_str()); - } else if (memcmp(uri, "search/", 7) == 0) { + } else if (strncmp(uri, "search/", 7) == 0) { const char *rest = uri + 7; u = xstrcatdup("https://api.soundcloud.com/tracks.json?q=", rest, "&client_id=", soundcloud_config.apikey.c_str()); - } else if (memcmp(uri, "url/", 4) == 0) { + } else if (strncmp(uri, "url/", 4) == 0) { const char *rest = uri + 4; /* Translate to soundcloud resolver call. libcurl will automatically follow the redirect to the right resource. */ diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx index edf9b1b92..6e00f7e34 100644 --- a/src/storage/plugins/NfsStorage.cxx +++ b/src/storage/plugins/NfsStorage.cxx @@ -389,7 +389,7 @@ NfsStorage::OpenDirectory(const char *uri_utf8) static Storage * CreateNfsStorageURI(EventLoop &event_loop, const char *base) { - if (memcmp(base, "nfs://", 6) != 0) + if (strncmp(base, "nfs://", 6) != 0) return nullptr; const char *p = base + 6; diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx index 0b4de5683..92702259a 100644 --- a/src/storage/plugins/SmbclientStorage.cxx +++ b/src/storage/plugins/SmbclientStorage.cxx @@ -182,7 +182,7 @@ SmbclientDirectoryReader::GetInfo(gcc_unused bool follow) static Storage * CreateSmbclientStorageURI(gcc_unused EventLoop &event_loop, const char *base) { - if (memcmp(base, "smb://", 6) != 0) + if (strncmp(base, "smb://", 6) != 0) return nullptr; SmbclientInit(); diff --git a/test/test_translate_song.cxx b/test/test_translate_song.cxx index 3b042b216..698218029 100644 --- a/test/test_translate_song.cxx +++ b/test/test_translate_song.cxx @@ -34,7 +34,7 @@ Log(const Domain &domain, gcc_unused LogLevel level, const char *msg) bool uri_supported_scheme(const char *uri) { - return memcmp(uri, "http://", 7) == 0; + return strncmp(uri, "http://", 7) == 0; } static constexpr auto music_directory = PATH_LITERAL("/music");