Browse Source

fix a buf issue

pull/399/head
Max Lv 9 years ago
parent
commit
703374cae8
5 changed files with 7 additions and 6 deletions
  1. 3
      src/encrypt.c
  2. 2
      src/encrypt.h
  3. 4
      src/local.c
  4. 2
      src/redir.c
  5. 2
      src/tunnel.c

3
src/encrypt.c

@ -1506,7 +1506,7 @@ int ss_check_crc(char *buf, ssize_t *buf_len, char *crc_buf, ssize_t *crc_idx)
return 1;
}
void ss_gen_crc(char *buf, ssize_t *buf_len, char *crc_buf, ssize_t *crc_idx, int buf_size)
char *ss_gen_crc(char *buf, ssize_t *buf_len, char *crc_buf, ssize_t *crc_idx, int buf_size)
{
int i, j;
ssize_t blen = *buf_len;
@ -1528,4 +1528,5 @@ void ss_gen_crc(char *buf, ssize_t *buf_len, char *crc_buf, ssize_t *crc_idx, in
}
*buf_len = j;
*crc_idx = cidx;
return buf;
}

2
src/encrypt.h

@ -173,6 +173,6 @@ int ss_onetimeauth(char *auth, char *msg, int msg_len);
int ss_onetimeauth_verify(char *auth, char *msg, int msg_len);
int ss_check_crc(char *buf, ssize_t *buf_len, char *crc_buf, ssize_t *crc_idx);
void ss_gen_crc(char *buf, ssize_t *buf_len, char *crc_buf, ssize_t *crc_idx, int buf_size);
char * ss_gen_crc(char *buf, ssize_t *buf_len, char *crc_buf, ssize_t *crc_idx, int buf_size);
#endif // _ENCRYPT_H

4
src/local.c

@ -245,7 +245,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
}
if (remote->send_ctx->connected && auth) {
ss_gen_crc(remote->buf, &r, remote->crc_buf, &remote->crc_idx, BUF_SIZE);
remote->buf = ss_gen_crc(remote->buf, &r, remote->crc_buf, &remote->crc_idx, BUF_SIZE);
}
// insert shadowsocks header
@ -484,7 +484,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
memcpy(remote->buf, ss_addr_to_send, addr_len);
if (auth) {
ss_gen_crc(buf, &r, remote->crc_buf, &remote->crc_idx, BUF_SIZE);
buf = ss_gen_crc(buf, &r, remote->crc_buf, &remote->crc_idx, BUF_SIZE);
}
if (r > 0) {

2
src/redir.c

@ -185,7 +185,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
}
if (auth) {
ss_gen_crc(remote->buf, &r, remote->crc_buf, &remote->crc_idx, BUF_SIZE);
remote->buf = ss_gen_crc(remote->buf, &r, remote->crc_buf, &remote->crc_idx, BUF_SIZE);
}
remote->buf = ss_encrypt(BUF_SIZE, remote->buf, &r, server->e_ctx);

2
src/tunnel.c

@ -197,7 +197,7 @@ static void server_recv_cb(EV_P_ ev_io *w, int revents)
}
if (auth) {
ss_gen_crc(remote->buf, &r, remote->crc_buf, &remote->crc_idx, BUF_SIZE);
remote->buf = ss_gen_crc(remote->buf, &r, remote->crc_buf, &remote->crc_idx, BUF_SIZE);
}
remote->buf = ss_encrypt(BUF_SIZE, remote->buf, &r, server->e_ctx);

Loading…
Cancel
Save