From 47b2f50baaa9555f1d92cac8ebabc878c7892d21 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 4 Sep 2017 10:54:34 +0200 Subject: [PATCH] Fix Omitted Content-Length not handled anymore YAZ-894 This issue was introduced by work in YAZ-878 YAZ Version 5.20.1. --- src/comstack.c | 6 +++++- test/test_comstack.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/comstack.c b/src/comstack.c index ea5b3eef6..6f1f847ef 100644 --- a/src/comstack.c +++ b/src/comstack.c @@ -381,6 +381,8 @@ static int cs_complete_http(const char *buf, int len, int head_only) head_only = 1; else if (!memcmp(buf + j, "304", 3)) head_only = 1; + else + content_len = -1; break; } } @@ -406,7 +408,9 @@ static int cs_complete_http(const char *buf, int len, int head_only) return cs_read_chunk(buf, i, len); else { /* not chunked ; inside body */ - if (len >= i + content_len) + if (content_len == -1) + return 0; /* no content length */ + else if (len >= i + content_len) { return i + content_len; } diff --git a/test/test_comstack.c b/test/test_comstack.c index 3638d50b7..381ecb88f 100644 --- a/test/test_comstack.c +++ b/test/test_comstack.c @@ -170,7 +170,7 @@ static void tst_http_response(void) YAZ_CHECK_EQ(cs_complete_auto(http_buf, 1), 0); YAZ_CHECK_EQ(cs_complete_auto(http_buf, 2), 0); - YAZ_CHECK_EQ(cs_complete_auto(http_buf, 24), 19); + YAZ_CHECK_EQ(cs_complete_auto(http_buf, 24), 0); } { /* no content, no headers */