diff --git a/binaries/aarch64/tpws b/binaries/aarch64/tpws index 75a1120..ebb9f76 100755 Binary files a/binaries/aarch64/tpws and b/binaries/aarch64/tpws differ diff --git a/binaries/arm/tpws b/binaries/arm/tpws index eadd340..345e040 100755 Binary files a/binaries/arm/tpws and b/binaries/arm/tpws differ diff --git a/binaries/freebsd-x64/tpws b/binaries/freebsd-x64/tpws index e9c7322..e540b38 100755 Binary files a/binaries/freebsd-x64/tpws and b/binaries/freebsd-x64/tpws differ diff --git a/binaries/mac64/tpws b/binaries/mac64/tpws index fbf180e..84b2bd4 100755 Binary files a/binaries/mac64/tpws and b/binaries/mac64/tpws differ diff --git a/binaries/mips32r1-lsb/tpws b/binaries/mips32r1-lsb/tpws index 7a717dc..1afa09c 100755 Binary files a/binaries/mips32r1-lsb/tpws and b/binaries/mips32r1-lsb/tpws differ diff --git a/binaries/mips32r1-msb/tpws b/binaries/mips32r1-msb/tpws index 00d6bdc..5b1300b 100755 Binary files a/binaries/mips32r1-msb/tpws and b/binaries/mips32r1-msb/tpws differ diff --git a/binaries/mips64r2-msb/tpws b/binaries/mips64r2-msb/tpws index 92b64b1..89862ae 100755 Binary files a/binaries/mips64r2-msb/tpws and b/binaries/mips64r2-msb/tpws differ diff --git a/binaries/ppc/tpws b/binaries/ppc/tpws index 0d68196..526d192 100755 Binary files a/binaries/ppc/tpws and b/binaries/ppc/tpws differ diff --git a/binaries/x86/tpws b/binaries/x86/tpws index 32ffc08..dfd008e 100755 Binary files a/binaries/x86/tpws and b/binaries/x86/tpws differ diff --git a/binaries/x86_64/tpws b/binaries/x86_64/tpws index ae88a73..0b49cbe 100755 Binary files a/binaries/x86_64/tpws and b/binaries/x86_64/tpws differ diff --git a/binaries/x86_64/tpws_wsl.tgz b/binaries/x86_64/tpws_wsl.tgz index 7fae087..639872c 100644 Binary files a/binaries/x86_64/tpws_wsl.tgz and b/binaries/x86_64/tpws_wsl.tgz differ diff --git a/tpws/tpws_conn.c b/tpws/tpws_conn.c index 7b14c6d..c9b757e 100644 --- a/tpws/tpws_conn.c +++ b/tpws/tpws_conn.c @@ -154,6 +154,25 @@ static bool send_buffer_create(send_buffer_t *sb, const void *data, size_t len, sb->flags = flags; return true; } +static bool send_buffer_realloc(send_buffer_t *sb, size_t extra_bytes) +{ + if (sb->data) + { + uint8_t *p = (uint8_t*)realloc(sb->data, sb->len + extra_bytes); + if (p) + { + sb->data = p; + DBGPRINT("reallocated send_buffer from %zd to %zd", sb->len, sb->len + extra_bytes) + return true; + } + else + { + DBGPRINT("failed to realloc send_buffer from %zd to %zd", sb->len, sb->len + extra_bytes) + } + } + return false; +} + static void send_buffer_free(send_buffer_t *sb) { if (sb->data) @@ -1117,7 +1136,10 @@ static bool read_all_and_buffer(tproxy_conn_t *conn, int buffer_number) conn->partner->bFlowOut = true; size_t split_pos; - tamper(conn, conn->partner->wr_buf[buffer_number].data, numbytes, &conn->partner->wr_buf[buffer_number].len, &split_pos); + + // tamper may increase data block size by up to 5 bytes + if (send_buffer_realloc(conn->partner->wr_buf+buffer_number,5)) + tamper(conn, conn->partner->wr_buf[buffer_number].data, numbytes, &conn->partner->wr_buf[buffer_number].len, &split_pos); if (epoll_update_flow(conn->partner)) return true;