2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

2849. [bug] Don't treat errors from the xml2 library as fatal.

[RT #20945]
This commit is contained in:
Mark Andrews
2010-02-04 00:57:25 +00:00
parent db95cc18d8
commit 8ac908b38a
3 changed files with 260 additions and 134 deletions

View File

@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
/* $Id: httpd.c,v 1.16 2008/08/08 05:06:49 marka Exp $ */
/* $Id: httpd.c,v 1.17 2010/02/04 00:57:25 marka Exp $ */
/*! \file */
@@ -151,6 +151,7 @@ struct isc_httpdmgr {
ISC_LIST(isc_httpdurl_t) urls; /*%< urls we manage */
isc_httpdaction_t *render_404;
isc_httpdaction_t *render_500;
};
/*%
@@ -221,6 +222,11 @@ static isc_result_t render_404(const char *, const char *,
unsigned int *, const char **,
const char **, isc_buffer_t *,
isc_httpdfree_t **, void **);
static isc_result_t render_500(const char *, const char *,
void *,
unsigned int *, const char **,
const char **, isc_buffer_t *,
isc_httpdfree_t **, void **);
static void
destroy_client(isc_httpd_t **httpdp)
@@ -300,6 +306,7 @@ isc_httpdmgr_create(isc_mem_t *mctx, isc_socket_t *sock, isc_task_t *task,
goto cleanup;
httpd->render_404 = render_404;
httpd->render_500 = render_500;
*httpdp = httpd;
return (ISC_R_SUCCESS);
@@ -623,6 +630,30 @@ render_404(const char *url, const char *querystring,
return (ISC_R_SUCCESS);
}
static isc_result_t
render_500(const char *url, const char *querystring,
void *arg,
unsigned int *retcode, const char **retmsg,
const char **mimetype, isc_buffer_t *b,
isc_httpdfree_t **freecb, void **freecb_args)
{
static char msg[] = "Internal server failure.";
UNUSED(url);
UNUSED(querystring);
UNUSED(arg);
*retcode = 500;
*retmsg = "Internal server failure";
*mimetype = "text/plain";
isc_buffer_reinit(b, msg, strlen(msg));
isc_buffer_add(b, strlen(msg));
*freecb = NULL;
*freecb_args = NULL;
return (ISC_R_SUCCESS);
}
static void
isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev)
{
@@ -691,8 +722,14 @@ isc_httpd_recvdone(isc_task_t *task, isc_event_t *ev)
&httpd->mimetype, &httpd->bodybuffer,
&httpd->freecb, &httpd->freecb_arg);
if (result != ISC_R_SUCCESS) {
destroy_client(&httpd);
goto out;
result = httpd->mgr->render_500(httpd->url, httpd->querystring,
NULL,
&httpd->retcode,
&httpd->retmsg,
&httpd->mimetype,
&httpd->bodybuffer,
&httpd->freecb,
&httpd->freecb_arg);
}
isc_httpd_response(httpd);