fix: Fix array access for setting port to inactive

This commit is contained in:
Tristan Russell 2025-01-17 21:16:36 -05:00
parent 425062ab5c
commit 9e355db588
1 changed files with 2 additions and 1 deletions

3
main.c
View File

@ -1,4 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
@ -70,7 +71,7 @@ int assign_workers(int* socket_fd) {
memcpy(&port, buffer+1, sizeof(u_int32_t)); memcpy(&port, buffer+1, sizeof(u_int32_t));
port = ntohl(port); port = ntohl(port);
printf("[Host] Unassigning port %i\n", port); printf("[Host] Unassigning port %i\n", port);
ports[11000-port] = false; ports[abs(11000-port)] = false;
shutdown(client_sock, SHUT_RDWR); shutdown(client_sock, SHUT_RDWR);
close(client_sock); close(client_sock);
} }