From 5b32a774c57d8797fa2725979a69522b754bbb6c Mon Sep 17 00:00:00 2001 From: Max Lv Date: Wed, 17 Apr 2013 19:15:54 +0800 Subject: [PATCH] fix a buffer corruption --- src/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server.c b/src/server.c index 9d482368..093459c3 100644 --- a/src/server.c +++ b/src/server.c @@ -259,7 +259,7 @@ static void server_recv_cb (EV_P_ ev_io *w, int revents) { return; } - // XXX: should handel buffer carefully + // XXX: should handle buffer carefully if (r > offset) { server->buf_len = r - offset; server->buf_idx = offset; @@ -401,7 +401,7 @@ static void server_resolve_cb(EV_P_ ev_timer *watcher, int revents) { // XXX: should handel buffer carefully if (server->buf_len > 0) { - memcpy(remote->buf, server->buf, server->buf_len); + memcpy(remote->buf, server->buf + server->buf_idx, server->buf_len); remote->buf_len = server->buf_len; remote->buf_idx = 0; server->buf_len = 0;