571504b8602e77298d8b8d7cbdf5bddc348e6020 angie Fri Sep 21 15:53:28 2018 -0700 hgSuggest, when invoked with no params, was getting a SEGV instead of printing a 'Status: 400' header and error message. There were two problems: a param was being used before the test for lack of params, and htmlVaBadRequestAbort was used only as an AbortHandler -- it needs to be a WarnHandler, otherwise the error message is printed out before the header. A couple other places also needed to install htmlVaBadRequestAbort as a WarnHandler not just AbortHandler. diff --git src/lib/htmshell.c src/lib/htmshell.c index a4cc98b..8612c0d 100644 --- src/lib/htmshell.c +++ src/lib/htmshell.c @@ -691,37 +691,39 @@ // NOTE that "--ERROR --" is needed at the end of this print!! dyStringFree(&dy); freeMem(jsEncodedMessage); /* Log useful CGI info to stderr */ logCgiToStderr(); /* write warning/error message to stderr so they get logged. */ vfprintf(stderr, format, argscp); fprintf(stderr, "\n"); fflush(stderr); va_end(argscp); } void htmlVaBadRequestAbort(char *format, va_list args) -/* Print out an HTTP header 400 status code (Bad Request) and message, - * then exit with error. For use as an errAbort handler. */ +/* Print out an HTTP header 400 status code (Bad Request) and message, then exit with error. + * NOTE: This must be installed using pushWarnHandler (pushAbortHandler optional) because + * vaErrAbort calls vaWarn and then noWarnAbort. So if the defaut warn handler is used, then + * the error message will be printed out by defaultVaWarn before this prints out the header. */ { puts("Status: 400\r"); puts("Content-Type: text/plain; charset=UTF-8\r"); puts("\r"); -if (format != NULL) +if (format != NULL && args != NULL) { vfprintf(stdout, format, args); fprintf(stdout, "\n"); } exit(-1); } void htmlAbort() /* Terminate HTML file. */ { longjmp(htmlRecover, -1); } void htmlMemDeath() {