libcgi icon indicating copy to clipboard operation
libcgi copied to clipboard

Avoid use of `libcgi_error()` and add real error handling

Open LeSpocky opened this issue 7 years ago • 0 comments

That API function is problematic in multiple ways:

  • exit terminates the whole process, from a library, … well you don't do that, pass your error codes and let the application decide!
  • cgi_init_headers() is called, if you want or not
  • no actual error handling, which could lead to all kinds of null pointer dereferences, use after free, and so on :-/
  • all depending on global variable cgi_display_errors (initialized with 1 aka true)
    • if cgi_display_errors is set, the process will be terminated (see above)
    • if cgi_display_errors is not set, libcgi_error() returns short and there's actually no error handling at all (see above)
  • the function is exposed to the API, so a consumer could call it: WHY? o.O

NOTE: just avoiding libcgi_error() does not solve that missing error handling!

LeSpocky avatar Nov 16 '18 08:11 LeSpocky