Browse Source

tpws: fix crash when tampering is applied without remote end

pull/178/head
bol-van 1 year ago
parent
commit
77520d7f8b
  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. 12
      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.

12
tpws/tpws_conn.c

@ -134,14 +134,14 @@ ssize_t send_with_ttl(int fd, const void *buf, size_t len, int flags, int ttl)
} }
static bool send_buffer_create(send_buffer_t *sb, const void *data, size_t len, int flags, int ttl) static bool send_buffer_create(send_buffer_t *sb, const void *data, size_t len, size_t extra_bytes, int flags, int ttl)
{ {
if (sb->data) if (sb->data)
{ {
fprintf(stderr,"FATAL : send_buffer_create but buffer is not empty\n"); fprintf(stderr,"FATAL : send_buffer_create but buffer is not empty\n");
exit(1); exit(1);
} }
sb->data = malloc(len); sb->data = malloc(len + extra_bytes);
if (!sb->data) if (!sb->data)
{ {
DBGPRINT("send_buffer_create failed. errno=%d",errno) DBGPRINT("send_buffer_create failed. errno=%d",errno)
@ -288,7 +288,7 @@ static ssize_t send_or_buffer(send_buffer_t *sb, int fd, const void *buf, size_t
if (wr<0 && errno==EAGAIN) wr=0; if (wr<0 && errno==EAGAIN) wr=0;
if (wr>=0 && wr<len) if (wr>=0 && wr<len)
{ {
if (!send_buffer_create(sb, buf+wr, len-wr, flags, ttl)) if (!send_buffer_create(sb, buf+wr, len-wr, 0, flags, ttl))
wr=-1; wr=-1;
} }
} }
@ -1125,7 +1125,7 @@ static bool read_all_and_buffer(tproxy_conn_t *conn, int buffer_number)
DBGPRINT("read_all_and_buffer(%d) numbytes=%d",buffer_number,numbytes) DBGPRINT("read_all_and_buffer(%d) numbytes=%d",buffer_number,numbytes)
if (numbytes>0) if (numbytes>0)
{ {
if (send_buffer_create(conn->partner->wr_buf+buffer_number, NULL, numbytes, 0, 0)) if (send_buffer_create(conn->partner->wr_buf+buffer_number, NULL, numbytes, 5, 0, 0))
{ {
ssize_t rd = recv(conn->fd, conn->partner->wr_buf[buffer_number].data, numbytes, MSG_DONTWAIT); ssize_t rd = recv(conn->fd, conn->partner->wr_buf[buffer_number].data, numbytes, MSG_DONTWAIT);
if (rd>0) if (rd>0)
@ -1137,9 +1137,7 @@ static bool read_all_and_buffer(tproxy_conn_t *conn, int buffer_number)
size_t split_pos; size_t split_pos;
// tamper may increase data block size by up to 5 bytes tamper(conn, conn->partner->wr_buf[buffer_number].data, numbytes+5, &conn->partner->wr_buf[buffer_number].len, &split_pos);
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