kristapsdz / kcgi

minimal CGI and FastCGI library for C/C++
https://kristaps.bsd.lv/kcgi
ISC License
275 stars 40 forks source link

Buffer log message before writing to stderr #79

Closed xwhatsit closed 4 years ago

xwhatsit commented 4 years ago

As discussed in #75.

This uses dynamic allocation for the log message, although it needs a couple of stabs at it because of the varargs (vasprintf(), then asprintf()).

I wouldn't say it's particularly pretty, but it fixes #75 and eliminates the fixed buffer and trusted lvl and ident inputs. The err string is still trusted, but it's only supplied by strerror, so should be OK.

I've fuzzed it by taking 8 kB+ input from /dev/urandom, and valgrind (at least on Linux) seems happy.