Browse Source

tpws: fix crash when tampering is applied without remote end

pull/178/head
bol-van 1 year ago
parent
commit
d82c298114
  1. BIN
      binaries/aarch64/tpws
  2. BIN
      binaries/arm/tpws
  3. BIN
      binaries/freebsd-x64/tpws
  4. BIN
      binaries/mac64/tpws
  5. BIN
      binaries/mips32r1-lsb/tpws
  6. BIN
      binaries/mips32r1-msb/tpws
  7. BIN
      binaries/mips64r2-msb/tpws
  8. BIN
      binaries/ppc/tpws
  9. BIN
      binaries/x86/tpws
  10. BIN
      binaries/x86_64/tpws
  11. BIN
      binaries/x86_64/tpws_wsl.tgz
  12. 24
      tpws/tpws_conn.c

BIN
binaries/aarch64/tpws

Binary file not shown.

BIN
binaries/arm/tpws

Binary file not shown.

BIN
binaries/freebsd-x64/tpws

Binary file not shown.

BIN
binaries/mac64/tpws

Binary file not shown.

BIN
binaries/mips32r1-lsb/tpws

Binary file not shown.

BIN
binaries/mips32r1-msb/tpws

Binary file not shown.

BIN
binaries/mips64r2-msb/tpws

Binary file not shown.

BIN
binaries/ppc/tpws

Binary file not shown.

BIN
binaries/x86/tpws

Binary file not shown.

BIN
binaries/x86_64/tpws

Binary file not shown.

BIN
binaries/x86_64/tpws_wsl.tgz

Binary file not shown.

24
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; sb->flags = flags;
return true; 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) static void send_buffer_free(send_buffer_t *sb)
{ {
if (sb->data) if (sb->data)
@ -1117,7 +1136,10 @@ static bool read_all_and_buffer(tproxy_conn_t *conn, int buffer_number)
conn->partner->bFlowOut = true; conn->partner->bFlowOut = true;
size_t split_pos; 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)) if (epoll_update_flow(conn->partner))
return true; return true;

Loading…
Cancel
Save