Scheduler: on timeout, validate incomplete linked list (#163)

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Request: unlink request node from cs->request_lists

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Request: set correct path size when truncated

If snprintf can't write the entire string out to the buffer, it will
still null-terminate it. Hence, the length of the string is one less
than the maximum passed in, not the maximum itself.

Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Mimetype: don't iterate off the start of the filename when looking for an extension

Check the iterator position before checking for an extension.

Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Method: correctly extract content length value from body buffer when pre-parsing

The buffer offset and the end position passed to mk_string_copy_substr
is incorrect.

Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Request: don't search off the end of the body buffer for query strings

mk_string_char_search takes a length, not an end position.

Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Utils: allocate enough space to include the null terminator when URL-decoding URLs

Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Request: new request session flag to mark those files opened by FDT

This patch aims to fix a potential DDoS problem that can be caused
in the server quering repetitive non-existent resources.

When serving a static file, the core use Vhost FDT mechanism, but if
it sends a static error page it does a direct open(2). When closing
the resources for the same request it was just calling mk_vhost_close()
which did not clear properly the file descriptor.

This patch adds a new field on the struct session_request called 'fd_is_fdt',
which contains MK_TRUE or MK_FALSE depending of how fd_file was opened.

Thanks to Matthew Daley <mattd@bugfuzz.com> for report and troubleshoot this
problem.

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Mandril: fix network address reference

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Macros: document NET macros parameters

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Mandril: remove trace msg

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Epoll: validate when registering connection with the Scheduler

In the epoll event loop, when registering a new connection with
the Scheduler, there were not check if this was successfull or not,
a common example may be a security plugin dropping a connection
at STAGE_10.

This patch adds a validation on the return value when trying to register
a connection with the Scheduler. If it fails, the socket will be closed
right away.

Signed-off-by: Eduardo Silva <eduardo@monkey.io>
Merge branch 'master' of https://github.com/monkey/monkey into ldpreload