From 697b7bdf2d62e6590b8a40bf6faf098e432fb57b Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 5 May 2019 19:20:27 +0200 Subject: [PATCH] Revert "Fixed partial send data offset and memory leak" This reverts commit f34eabd55afafde2faf5174a7a48812c923596db. --- app/src/main/jni/netguard/tcp.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/app/src/main/jni/netguard/tcp.c b/app/src/main/jni/netguard/tcp.c index 65d27598..414e893b 100644 --- a/app/src/main/jni/netguard/tcp.c +++ b/app/src/main/jni/netguard/tcp.c @@ -485,26 +485,20 @@ void check_tcp_socket(const struct arguments *args, fwd = 1; buffer_size -= sent; s->tcp.sent += sent; - s->tcp.remote_seq = s->tcp.forward->seq + sent; + s->tcp.forward->seq += sent; + s->tcp.forward->len -= sent; + s->tcp.remote_seq = s->tcp.forward->seq; - if (sent != s->tcp.forward->len) { + if (s->tcp.forward->len == 0) { + struct segment *p = s->tcp.forward; + s->tcp.forward = s->tcp.forward->next; + free(p->data); + free(p); + } else { log_android(ANDROID_LOG_WARN, "%s partial send %u/%u", session, sent, s->tcp.forward->len); - - struct segment *n = malloc(sizeof(struct segment)); - n->seq = s->tcp.forward->seq + sent; - n->len = s->tcp.forward->len - (uint16_t) sent; - n->data = malloc(n->len); - memcpy(n->data, s->tcp.forward->data + sent, n->len); - n->psh = s->tcp.forward->psh; - n->next = s->tcp.forward->next; - s->tcp.forward->next = n; + break; } - - struct segment *p = s->tcp.forward; - s->tcp.forward = s->tcp.forward->next; - free(p->data); - free(p); } }