fix: invalid index

This commit is contained in:
ruti 2024-05-02 21:23:14 +03:00
parent f0dab7dd56
commit d2da43aa82
2 changed files with 10 additions and 5 deletions

View File

@ -17,8 +17,8 @@
#include "error.h"
#include "params.h"
#include <desync.h>
#include <packets.h>
#include "desync.h"
#include "packets.h"
int set_timeout(int fd, unsigned int s)
@ -90,7 +90,7 @@ int ext_connect(struct poolhd *pool, struct eval *val,
struct sockaddr_ina *dst, int next, int m)
{
struct desync_params *dp = &params.dp[m];
if (dp->to_ip == 2) {
if (dp->to_ip) {
struct sockaddr_ina addr = { .in6 = dp->addr };
if (!addr.in.sin_port) {
addr.in.sin_port = dst->in.sin_port;
@ -106,7 +106,8 @@ int connect_hook(struct poolhd *pool, struct eval *val,
{
int m = mode_add_get(dst, -1);
val->cache = (m == 0);
val->attempt = m < 0 ? 0 : m;
m = m < 0 ? 0 : m;
val->attempt = m;
if (params.late_conn) {
val->type = EV_DESYNC;

6
main.c
View File

@ -416,6 +416,10 @@ void clear_params(void)
free(s.parts);
s.parts = 0;
}
if (s.tlsrec != 0) {
free(s.tlsrec);
s.tlsrec = 0;
}
if (s.fake_data.data) {
FREE_MAP(s.fake_data.data, s.fake_data.size);
s.fake_data.data = 0;
@ -659,7 +663,7 @@ int main(int argc, char **argv)
if (get_addr_with_port(optarg, (struct sockaddr_ina *)&dp->addr) < 0)
invalid = 1;
else
dp->to_ip = 2;
dp->to_ip = 1;
break;
case 's':