Make sure the getsfunc_*() functions used by ap_scan_script_header_err*() NUL-terminate the resulting string, even in case of an error. mod_cgi and mod_cgid try to log incomplete output from CGI scripts.