fixed a crashing bug in ursd when a rewriter terminates prematurely.

changed urs code to truncate the trailing string after the  first space in the response from ursd/rewriter
This commit is contained in:
hyung-hwan 2014-08-29 16:16:40 +00:00
parent 433686b599
commit adda075fe9
2 changed files with 29 additions and 20 deletions

View File

@ -726,19 +726,22 @@ static void dispatch_mux_event (qse_mux_t* mux, const qse_mux_evt_t* evt)
/* read failure or end of input */
rewriter->faulty = 1;
release_rewriter (mux_xtn->ursd, rewriter, 1);
/* TODO: error logging */
}
else
{
rewriter->req.outlen += x;
qse_printf (QSE_T("READ %d, %d bytes from pipes [%.*hs]\n"), (int)x, (int)rewriter->req.outlen, (int)rewriter->req.outlen, pkt->url);
if (rewriter->req.outlen > maxoutlen)
{
/* the rewriter returns too long a result */
rewriter->faulty = 1;
release_rewriter (mux_xtn->ursd, rewriter, 1);
/* TODO: error logging */
}
qse_printf (QSE_T("READ %d, %d bytes from pipes [%.*hs]\n"), (int)x, (int)rewriter->req.outlen, (int)rewriter->req.outlen, pkt->url);
if (pkt->url[rewriter->req.outlen - 1] == QSE_MT('\n'))
else if (pkt->url[rewriter->req.outlen - 1] == QSE_MT('\n'))
{
/* the last byte is a new line. i don't really care about
* new lines in the middle of data. the rewriter must
@ -755,6 +758,7 @@ qse_printf (QSE_T("READ %d, %d bytes from pipes [%.*hs]\n"), (int)x, (int)rewrit
release_rewriter (mux_xtn->ursd, rewriter, 0);
}
}
/* TODO: is the complete output is not received within time, some actions must be taken. timer based... rewrite timeout */
}

View File

@ -220,6 +220,7 @@ static int urs_recv (qse_httpd_t* httpd, qse_httpd_urs_t* urs, qse_ubi_t handle)
qse_ssize_t len, url_len;
urs_pkt_t* pkt;
urs_req_t* req;
qse_mchar_t* spc;
printf ("URS_RECV............................................\n");
@ -247,6 +248,10 @@ printf ("URS_RECV............................................\n");
/* null-terminate the url for easier processing */
pkt->url[url_len] = QSE_MT('\0');
/* drop trailers starting from the first space onwards */
spc = qse_mbschr (pkt->url, QSE_MT(' '));
if (spc) *spc = QSE_MT('\0');
urs_remove_tmr_tmout (httpd, req);
req->rewrite (httpd, req->pkt->url, pkt->url, req->ctx);