Skip to content

Commit

Permalink
Merge pull request #66 from clowwindy/master
Browse files Browse the repository at this point in the history
Fix compatibility issues
  • Loading branch information
madeye committed Apr 19, 2014
2 parents 3511f23 + 81159f9 commit 1c02395
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/udprelay.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents)

struct sockaddr src_addr;
socklen_t src_addr_len = sizeof(src_addr);
unsigned int addr_header_len = remote_ctx->addr_header_len;
char *buf = malloc(BUF_SIZE);

// recv
Expand Down Expand Up @@ -515,16 +514,19 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents)
}

int len = parse_udprealy_header(buf, buf_len, NULL, NULL);
if (len == 0 || len != addr_header_len)
if (len == 0)
{
LOGD("[udp] Error in parse header");
// error in parse header
goto CLEAN_UP;
}
// server may return using a different address type other than the type we
// have used during sending

#ifdef UDPRELAY_TUNNEL
// Construct packet
buf_len -= addr_header_len;
memmove(buf, buf + addr_header_len, buf_len);
buf_len -= len;
memmove(buf, buf + len, buf_len);
#else
// Construct packet
char *tmpbuf = malloc(buf_len + 3);
Expand All @@ -537,6 +539,9 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents)
#endif

#ifdef UDPRELAY_REMOTE

unsigned int addr_header_len = remote_ctx->addr_header_len;

// Construct packet
char *tmpbuf = malloc(buf_len + addr_header_len);
memcpy(tmpbuf, remote_ctx->addr_header, addr_header_len);
Expand Down

0 comments on commit 1c02395

Please sign in to comment.