NHariman / foodserv

A functional HTTP server written in C++ capable of sending and receiving HTTP requests, displaying websites and its content and executing CGIs
0 stars 2 forks source link

Custom error page bad path causing segfault #74

Closed MichelleJiam closed 2 years ago

MichelleJiam commented 2 years ago

Context

When testing the error_page directive in the config file, giving a non-existant file path for a custom 404 error page causes the server to segfault if it would try to serve that error page.

Problem

Edge case. The issue was if the custom error page would be for the 404 error specifically. ResponseHandler would get into an infinite loop while attempting the following steps:

Solution

Added a check to ResponseHandler::HandleCustomError for if the newly-thrown (internal) error code is the same as which was originally requested. If so, it serves the default error page instead.