diff --git a/src/plugins/http/src/httpParser.c b/src/plugins/http/src/httpParser.c index 4ce54a8ee630579499fe498e5d8c155bb5916eea..18cea56cfe6e0d1e8a4f833a920e5473536e1c7e 100644 --- a/src/plugins/http/src/httpParser.c +++ b/src/plugins/http/src/httpParser.c @@ -110,7 +110,7 @@ static void httpCleanupString(HttpString *str) { static int32_t httpAppendString(HttpString *str, const char *s, int32_t len) { if (str->size == 0) { str->pos = 0; - str->size = 64; + str->size = len + 1; str->str = malloc(str->size); } else if (str->pos + len + 1 >= str->size) { str->size += len; @@ -715,10 +715,12 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state, if (parser->method) { ok = httpOnRequestLine(parser, parser->method, parser->target, parser->version); + /* if (parser->target) { free(parser->target); parser->target = NULL; } + */ } httpClearString(&parser->str); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 8f3c51d2a9688690d3b4331a762ce917e9d487cb..b2d97e2d6935096ed5171d5284cfcb1987e36535 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -2747,7 +2747,10 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag, } if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { - tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type); + int32_t maxLen = bytes - VARSTR_HEADER_SIZE; + int32_t len = (varDataLen(val) > maxLen)? maxLen:varDataLen(val); + tVariantCreateFromBinary(tag, varDataVal(val), len, type); + //tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type); } else { tVariantCreateFromBinary(tag, val, bytes, type); } @@ -6539,8 +6542,15 @@ static void doSetTagValueToResultBuf(char* output, const char* val, int16_t type return; } - if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { - memcpy(output, val, varDataTLen(val)); + if (IS_VAR_DATA_TYPE(type)) { + // Binary data overflows for sort of unknown reasons. Let trim the overflow data + if (varDataTLen(val) > bytes) { + int32_t len = bytes - VARSTR_HEADER_SIZE; // remain available space + memcpy(varDataVal(output), varDataVal(val), len); + varDataSetLen(output, len); + } else { + varDataCopy(output, val); + } } else { memcpy(output, val, bytes); }