This commit is contained in:
clowwindy
2013-06-06 02:21:49 +08:00
parent a8035316ee
commit 3ec1df3cb1
2 changed files with 3 additions and 3 deletions

View File

@@ -74,7 +74,7 @@ void decrypt_buf(struct encryption_ctx *ctx, char *buf, int *len) {
unsigned char *cipher_text = malloc(out_len);
EVP_CipherUpdate(ctx->ctx, cipher_text, &out_len, buf + iv_len, *len - iv_len);
memcpy(buf, cipher_text, out_len);
*len = out_len - iv_len;
*len = out_len;
free(cipher_text);
} else {
int out_len = *len + EVP_CIPHER_CTX_block_size(ctx->ctx);

View File

@@ -6,7 +6,6 @@
#include "local.h"
#include "socks5.h"
#include "table.h"
#include "encrypt.h"
#define ADDR_STR_LEN 512
@@ -304,7 +303,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) {
return;
}
while (1) {
ssize_t r = recv(remote->fd, server->buf, BUF_SIZE, 0);
int r = recv(remote->fd, server->buf, BUF_SIZE, 0);
if (r == 0) {
// connection closed
@@ -327,6 +326,7 @@ static void remote_recv_cb (EV_P_ ev_io *w, int revents) {
}
}
decrypt_buf(&(remote->recv_encryption_ctx), server->buf, &r);
NSLog(@"%@", [NSString stringWithCString:server->buf length:r]);
int w = send(server->fd, server->buf, r, 0);
if(w == -1) {
if (errno == EAGAIN) {