From: Arran Cudbard-Bell Date: Mon, 24 Jul 2017 16:33:58 +0000 (-0400) Subject: Only switch ctx->state after we've received all the header lines for a header. Fixes... X-Git-Tag: release_3_0_16~208 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=faac6f71b599b77ccf43545cde274b92b5d7e99a;p=thirdparty%2Ffreeradius-server.git Only switch ctx->state after we've received all the header lines for a header. Fixes #2027 --- diff --git a/src/modules/rlm_rest/rest.c b/src/modules/rlm_rest/rest.c index 918ca09eb04..8df8dbb3b95 100644 --- a/src/modules/rlm_rest/rest.c +++ b/src/modules/rlm_rest/rest.c @@ -1546,11 +1546,21 @@ static size_t rest_response_header(void *in, size_t size, size_t nmemb, void *us http_body_type_t type; /* - * Curl seems to throw these (\r\n) in before the next set of headers when - * looks like it's just a body separator and safe to ignore after we - * receive a 100 Continue. + * This seems to be curl's indication there are no more header lines. */ - if (t == 2 && ((p[0] == '\r') && (p[1] == '\n'))) return t; + if (t == 2 && ((p[0] == '\r') && (p[1] == '\n'))) { + /* + * If we got a 100 Continue, we need to send additional payload data. + * reset the state to WRITE_STATE_INIT, so that when were called again + * we overwrite previous header data with that from the proper header. + */ + if (ctx->code == 100) { + RDEBUG2("Continuing..."); + ctx->state = WRITE_STATE_INIT; + } + + return t; + } switch (ctx->state) { case WRITE_STATE_INIT: @@ -1698,16 +1708,6 @@ static size_t rest_response_header(void *in, size_t size, size_t nmemb, void *us break; } - /* - * If we got a 100 Continue, we need to send additional payload data. - * reset the state to WRITE_STATE_INIT, so that when were called again - * we overwrite previous header data with that from the proper header. - */ - if (ctx->code == 100) { - RDEBUG2("Continuing..."); - ctx->state = WRITE_STATE_INIT; - } - return t; malformed: