From 0ff2a52ef5265830b69f4d3afbbd823ed09b8557 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sat, 10 Apr 2010 10:07:57 +0000 Subject: [PATCH] * ReadPostData(): abort if we fail to read the whole content * session_loop(): allocate buffers after reading post data, so we don't have to free them on error * session_loop(): abort if reading post data fails --- webcit/webcit.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/webcit/webcit.c b/webcit/webcit.c index 292b12567..251c7df9a 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -473,8 +473,9 @@ void seconds_since_last_gexp(void) -void ReadPostData(void) +int ReadPostData(void) { + int rc; int body_start = 0; wcsession *WCC = WC; StrBuf *content = NULL; @@ -494,9 +495,12 @@ void ReadPostData(void) body_start = StrLength(content); /** Read the entire input data at once. */ - client_read_to(WCC->Hdr, content, - WCC->Hdr->HR.ContentLength, - SLEEPING); + rc = client_read_to(WCC->Hdr, content, + WCC->Hdr->HR.ContentLength, + SLEEPING); + if (rc < 0) + return rc; + if (!strncasecmp(ChrPtr(WCC->Hdr->HR.ContentType), "application/x-www-form-urlencoded", 33)) { StrBufCutLeft(content, body_start); @@ -517,6 +521,7 @@ void ReadPostData(void) content = NULL; } FreeStrBuf(&content); + return 1; } @@ -598,24 +603,24 @@ void session_loop(void) * so we can use them to reconnect a timed out session if we have to. */ wcsession *WCC; - - - Buf = NewStrBuf(); - + WCC= WC; - WCC->upload_length = 0; WCC->upload = NULL; WCC->is_mobile = 0; - WCC->trailing_javascript = NewStrBuf(); WCC->Hdr->nWildfireHeaders = 0; if (WCC->Hdr->HR.Handler != NULL) Flags = WCC->Hdr->HR.Handler->Flags; /* so we can temporarily add our own... */ if (WCC->Hdr->HR.ContentLength > 0) { - ReadPostData(); + if (ReadPostData() < 0) { + return; + } } + Buf = NewStrBuf(); + WCC->trailing_javascript = NewStrBuf(); + /* If there are variables in the URL, we must grab them now */ if (WCC->Hdr->PlainArgs != NULL) ParseURLParams(WCC->Hdr->PlainArgs); -- 2.30.2