From: Marc-André Moreau Date: Tue, 13 Nov 2012 23:57:46 +0000 (-0500) Subject: libfreerdp-core: workaround for fragmentation in HTTP header X-Git-Tag: 1.1.0-beta1~29^2~59^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=209bdd85b4622f2d79b3e98ccb7c50873c4bd229;p=platform%2Fupstream%2Ffreerdp.git libfreerdp-core: workaround for fragmentation in HTTP header --- diff --git a/libfreerdp/core/http.c b/libfreerdp/core/http.c index 1785e4c..1e7a1a6 100644 --- a/libfreerdp/core/http.c +++ b/libfreerdp/core/http.c @@ -22,6 +22,7 @@ #endif #include +#include #include @@ -405,28 +406,39 @@ HttpResponse* http_response_recv(rdpTls* tls) while (TRUE) { - status = tls_read(tls, p, length - nbytes); - - if (status > 0) - { - nbytes += status; - p = (BYTE*) &buffer[nbytes]; - } - else if (status == 0) - { - continue; - } - else - { - http_response_free(http_response); - return NULL; - break; - } + while (nbytes < 5) + { + status = tls_read(tls, p, length - nbytes); + + if (status > 0) + { + nbytes += status; + p = (BYTE*) &buffer[nbytes]; + } + else if (status == 0) + { + continue; + } + else + { + http_response_free(http_response); + return NULL; + } + } header_end = strstr((char*) buffer, "\r\n\r\n"); if (header_end) + { header_end += 2; + } + else + { + printf("http_response_recv: invalid response:\n"); + winpr_HexDump(buffer, status); + http_response_free(http_response); + return NULL; + } if (header_end != NULL) {