🔨」 fix: random crash when user skill issue

This commit is contained in:
2025-08-17 22:43:46 +02:00
parent 8c1c83229b
commit ab28a6d0e7
4 changed files with 17 additions and 19 deletions

View File

@ -18,7 +18,8 @@ typedef enum {
SIZE, SIZE,
TIMEOUT, TIMEOUT,
LINGER, LINGER,
INTERVAL INTERVAL,
TTL
} options_nb_t; } options_nb_t;
static struct options options[] = { static struct options options[] = {
@ -39,7 +40,7 @@ static struct options options[] = {
#undef GRP #undef GRP
}; };
#define OPT_NB 10 #define OPT_NB 9
#define FT_PING_V "0.1" #define FT_PING_V "0.1"

View File

@ -28,7 +28,7 @@ int init_socket(options_t opt) {
linger.l_onoff = true; linger.l_onoff = true;
if (setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger)) < 0) { if (setsockopt(sock, SOL_SOCKET, SO_LINGER, &linger, sizeof(linger)) < 0) {
fprintf(stderr, fprintf(stderr,
"can't setsockopt for the linger maybe try a different one"); "can't setsockopt for the linger maybe try a different one\n");
return -1; return -1;
} }
@ -38,8 +38,7 @@ int init_socket(options_t opt) {
if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv_out, sizeof(tv_out)) < if (setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, &tv_out, sizeof(tv_out)) <
0) { 0) {
perror("setsockopt"); fprintf(stderr, "can't setsockopt for the receive timeout\n");
fprintf(stderr, "can't setsockopt for the receive timeout");
return -1; return -1;
} }
return sock; return sock;

View File

@ -41,7 +41,6 @@ options_t init_opt(args_t *args) {
opt.interval = opt.interval =
args->arg[INTERVAL] != -1 ? args->arg[INTERVAL] : DEFAULT_INTERVAL; args->arg[INTERVAL] != -1 ? args->arg[INTERVAL] : DEFAULT_INTERVAL;
opt.linger = args->arg[LINGER] != -1 ? args->arg[LINGER] : DEFAULT_LINGER; opt.linger = args->arg[LINGER] != -1 ? args->arg[LINGER] : DEFAULT_LINGER;
return opt; return opt;
} }
@ -76,8 +75,7 @@ int send_ping(int socket, struct sockaddr_in *dest, options_t opt) {
} }
} }
} else } else
process_icmp(recvbuf, bytes, &addr, seq, &pkt_start, process_icmp(recvbuf, bytes, &addr, seq, &pkt_start, &pkt_end);
&pkt_end);
if (check_for_count(opt)) { if (check_for_count(opt)) {
print_stats(); print_stats();
return EXIT_SUCCESS; return EXIT_SUCCESS;