From f670c1c8a15420d9f80c87e85fa3a57de9b6e81a Mon Sep 17 00:00:00 2001 From: tastytea Date: Wed, 28 Nov 2018 17:29:08 +0100 Subject: [PATCH] Abort if favicon is requested. --- src/http.cpp | 5 +++++ src/libravatarserv.cpp | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/http.cpp b/src/http.cpp index 9ffccb9..a7a9add 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -26,6 +26,11 @@ using namespace http; const Request http::parse_request(const string &request) { + if (request.substr(0, 8) == "/favicon") + { + cout << "Status: 404 Not Found\n\n"; + std::exit(0); + } if (request.substr(0, 8) != "/avatar/" || request.find("..", 8) != std::string::npos) { diff --git a/src/libravatarserv.cpp b/src/libravatarserv.cpp index b5e0500..f6c1f0a 100644 --- a/src/libravatarserv.cpp +++ b/src/libravatarserv.cpp @@ -44,6 +44,7 @@ int main() cerr << "Error: ${REQUEST_URI} is empty.\n"; return 1; } + http::Request avatar = http::parse_request(request); if (!find_avatar_dir()) { @@ -54,8 +55,6 @@ int main() hash::fill_table(); read_settings(); - http::Request avatar = http::parse_request(request); - image::Image image = image::get(avatar.digest, avatar.size); if (image.error == 0) {