Don't crash on socks5

This commit is contained in:
Quentin Dufour 2019-03-20 17:02:23 +01:00
parent 6216935084
commit 429e66cbc8
2 changed files with 4 additions and 6 deletions

View file

@ -38,10 +38,11 @@ struct buffer_packet* get_read_buffer(struct algo_ctx *app_ctx, struct evt_core_
int waiting_count = 0;
g_hash_table_foreach(app_ctx->write_waiting, (GHFunc)iterate, &waiting_count);
g_hash_table_foreach(app_ctx->used_buffer, (GHFunc)iterate2, NULL);
fprintf(stderr, "total_buffers=%d, used_buffers=%d. free_buffer=%d, waiting_buffer=%d.\n",
fprintf(stderr, "total_buffers=%d, free_buffer=%d, used_buffers=%d, app_buffer=%d, write_buffer=%d.\n",
PACKET_BUFFER_SIZE,
g_hash_table_size(app_ctx->used_buffer),
app_ctx->free_buffer->length,
g_hash_table_size(app_ctx->used_buffer),
g_hash_table_size(app_ctx->application_waiting),
waiting_count);
// 2.1 If no buffer is available, we subscribe to be notified later
g_queue_push_tail (app_ctx->read_waiting, &(fdinfo->fd));

View file

@ -42,10 +42,7 @@ int socks5_reply(int sock) {
int res;
struct server_reply sr = {0};
res = read_entity(sock, &sr, sizeof(uint8_t) * 4);
if (res == -1) {
perror("read_entity");
exit(EXIT_FAILURE);
}
if (res == -1) goto read_error;
switch(sr.atyp) {
case ATYP_IPV4: