From 11da9b233a778df580be1aa2c7343567cf46ce8c Mon Sep 17 00:00:00 2001 From: Max Lv Date: Sat, 22 Feb 2014 14:00:43 +0800 Subject: [PATCH] fix the buffer corruption --- src/jconf.c | 3 ++- src/udprelay.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/jconf.c b/src/jconf.c index 510a55c6..dbe5352e 100644 --- a/src/jconf.c +++ b/src/jconf.c @@ -55,7 +55,8 @@ void parse_addr(const char *str, addr_t *addr) pch = strchr(pch + 1, ':'); } if (n > 1) { - if (strcmp(str+ret, "]") != 0) { + if (strcmp(str+ret, "]") != 0) + { ret = -1; } } diff --git a/src/udprelay.c b/src/udprelay.c index 40a536db..9f2a26cb 100644 --- a/src/udprelay.c +++ b/src/udprelay.c @@ -279,7 +279,7 @@ struct query_ctx *new_query_ctx(asyncns_query_t *query, ctx->buf_len = buf_len; memcpy(ctx->buf, buf, buf_len); ctx->query = query; - ev_timer_init(&ctx->watcher, query_resolve_cb, 0.2, 0.5); + ev_timer_init(&ctx->watcher, query_resolve_cb, 0.1, 0.2); return ctx; } @@ -610,6 +610,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) memcpy(tmp + addr_header_len, buf, buf_len); free(buf); buf = tmp; + buf_len += addr_header_len; #else char host[256] = {0};