Fixes some XSS and header injection problems and an int overflow in CONTENT_LENGTH resulting in buffer overflow