summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2016-01-23 19:49:55 +0100
committerFelix Fietkau <nbd@openwrt.org>2016-01-23 19:49:55 +0100
commit07b4860975bd919fc8a8ce75d14ca8216eab70aa (patch)
tree4660f42b185c0df8cfa6b2b25feea352f33d4640
parent4924411cff2e74d835b819151513367d08c9e524 (diff)
downloaduclient-07b4860975bd919fc8a8ce75d14ca8216eab70aa.tar.gz
http: fix processing server http data separated by \n instead of \r\n
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
-rw-r--r--uclient-http.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/uclient-http.c b/uclient-http.c
index 6fc30da..e58cf27 100644
--- a/uclient-http.c
+++ b/uclient-http.c
@@ -663,28 +663,33 @@ static void __uclient_notify_read(struct uclient_http *uh)
return;
if (uh->state < HTTP_STATE_RECV_DATA) {
- char *sep;
+ char *sep, *next;
int cur_len;
do {
- sep = strstr(data, "\r\n");
+ sep = strchr(data, '\n');
if (!sep)
break;
+ next = sep + 1;
+ if (sep > data && sep[-1] == '\r')
+ sep--;
+
/* Check for multi-line HTTP headers */
if (sep > data) {
- if (!sep[2])
+ if (!*next)
return;
- if (isspace(sep[2]) && sep[2] != '\r') {
+ if (isspace(*next) && *next != '\r' && *next != '\n') {
sep[0] = ' ';
- sep[1] = ' ';
+ if (sep + 1 < next)
+ sep[1] = ' ';
continue;
}
}
*sep = 0;
- cur_len = sep + 2 - data;
+ cur_len = next - data;
uclient_parse_http_line(uh, data);
if (seq != uh->seq)
return;