From acaefc098b6db21ad8a471f925c1e7489f62c9d2 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 25 Jan 2021 17:00:54 +0800 Subject: [PATCH 1/4] [TD-2832]: use httpDecodeUrl to parse reserved characters after percent-encoding --- src/plugins/http/src/httpParser.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/plugins/http/src/httpParser.c b/src/plugins/http/src/httpParser.c index b844834537..7fdd0a64f6 100644 --- a/src/plugins/http/src/httpParser.c +++ b/src/plugins/http/src/httpParser.c @@ -537,7 +537,7 @@ char *httpDecodeUrl(const char *enc) { dec = str.str; str.str = NULL; } - httpCleanupString(&str); + //httpCleanupString(&str); return dec; } @@ -648,7 +648,7 @@ static int32_t httpParserOnTarget(HttpParser *parser, HTTP_PARSER_STATE state, c } break; } - parser->target = strdup(parser->str.str); + parser->target = httpDecodeUrl(parser->str.str); if (!parser->target) { httpError("context:%p, fd:%d, parser state:%d, char:[%c]%02x, oom", pContext, pContext->fd, state, c, c); ok = -1; @@ -717,6 +717,10 @@ 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); From e3f623076134b8a2351de44a048e89f330263221 Mon Sep 17 00:00:00 2001 From: freemine Date: Mon, 25 Jan 2021 19:27:46 +0800 Subject: [PATCH 2/4] typo: value in semaphore_create --- src/os/src/darwin/darwinSemphone.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/src/darwin/darwinSemphone.c b/src/os/src/darwin/darwinSemphone.c index a9e470bd70..6df44a52b3 100644 --- a/src/os/src/darwin/darwinSemphone.c +++ b/src/os/src/darwin/darwinSemphone.c @@ -134,7 +134,7 @@ int tsem_init(tsem_t *sem, int pshared, unsigned int value) { errno = ENOMEM; return -1; } - kern_return_t ret = semaphore_create(sem_port, &p->sem, SYNC_POLICY_FIFO, 0); + kern_return_t ret = semaphore_create(sem_port, &p->sem, SYNC_POLICY_FIFO, value); if (ret != KERN_SUCCESS) { fprintf(stderr, "==%s[%d]%s():[%p]==semophore_create failed\n", basename(__FILE__), __LINE__, __func__, sem); // we fail-fast here, because we have less-doc about semaphore_create for the moment From b13a524d39f89af0d84efaeec9e4bebebe2f2b52 Mon Sep 17 00:00:00 2001 From: freemine Date: Mon, 25 Jan 2021 19:55:26 +0800 Subject: [PATCH 3/4] sizeof(time_t) is platform-dependent --- src/plugins/http/src/httpUtil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/http/src/httpUtil.c b/src/plugins/http/src/httpUtil.c index 7f1e2a94d1..abf02232e4 100644 --- a/src/plugins/http/src/httpUtil.c +++ b/src/plugins/http/src/httpUtil.c @@ -37,7 +37,7 @@ void httpTimeToString(time_t t, char *buf, int32_t buflen) { time_t tt = t / 1000; ptm = localtime(&tt); strftime(ts, 31, "%Y-%m-%d %H:%M:%S", ptm); - sprintf(buf, "%s.%03" PRId64, ts, t % 1000); + sprintf(buf, "%s.%03" PRId64, ts, (long long)(t % 1000)); } int32_t httpAddToSqlCmdBuffer(HttpContext *pContext, const char *const format, ...) { From 17de46555c2d8ffbb8fd70af6ecc6a635416f718 Mon Sep 17 00:00:00 2001 From: freemine Date: Mon, 25 Jan 2021 20:03:38 +0800 Subject: [PATCH 4/4] cast time_t to int64_t to satisfy PRId64 --- src/plugins/http/src/httpUtil.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/http/src/httpUtil.c b/src/plugins/http/src/httpUtil.c index abf02232e4..4fdd755b40 100644 --- a/src/plugins/http/src/httpUtil.c +++ b/src/plugins/http/src/httpUtil.c @@ -37,7 +37,7 @@ void httpTimeToString(time_t t, char *buf, int32_t buflen) { time_t tt = t / 1000; ptm = localtime(&tt); strftime(ts, 31, "%Y-%m-%d %H:%M:%S", ptm); - sprintf(buf, "%s.%03" PRId64, ts, (long long)(t % 1000)); + sprintf(buf, "%s.%03" PRId64, ts, (int64_t)(t % 1000)); } int32_t httpAddToSqlCmdBuffer(HttpContext *pContext, const char *const format, ...) {