Skip to content

Commit 2f4ea19

Browse files
committed
Fix build with GCC 14 and 15
Fix pointer type casts for shared memory variables: - Added explicit casts for pointers to match expected types: DATAlength, connection_data, LISTlength, mask, logged_connections, running_connections, TCP_nr_of_packets, TCP_bytes_in_packets, ICMP_nr_of_packets, UDP_nr_of_packets, UDP_bytes_in_packets, IP_nr_of_packets. - This resolves compiler warnings about incompatible pointer types when assigning from the shared memory block (SHARED). - No functionality was changed; only type safety and compatibility fixed.
1 parent 6992aba commit 2f4ea19

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/sniffit.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,20 +1876,20 @@ if (Plugin_Active[9] == 1)
18761876
printf ("Shared %zu\n", memsize);
18771877

18781878
/* set all pointers */
1879-
DATAlength = SHARED;
1880-
connection_data = DATAlength + sizeof (int);
1881-
LISTlength = connection_data + LENGTH_OF_INTERPROC_DATA;
1882-
mask = LISTlength + sizeof (int);
1883-
logged_connections = mask + sizeof (struct snif_mask);
1879+
DATAlength = (int *) SHARED;
1880+
connection_data = (char *) (DATAlength + 1);
1881+
LISTlength = (int *) (connection_data + LENGTH_OF_INTERPROC_DATA);
1882+
mask = (struct snif_mask *)((char *)LISTlength + sizeof(int));
1883+
logged_connections = (char *)mask + sizeof(struct snif_mask);
18841884
log_conn = (struct shared_logged_conn *) logged_connections;
1885-
running_connections = logged_connections + sizeof (struct shared_logged_conn);
1886-
TCP_nr_of_packets = (void *)running_connections + (sizeof (struct shared_conn_data) * CONNECTION_CAPACITY);
1887-
TCP_bytes_in_packets = TCP_nr_of_packets + sizeof (int);
1888-
ICMP_nr_of_packets = TCP_bytes_in_packets + sizeof (unsigned long);
1889-
UDP_nr_of_packets = ICMP_nr_of_packets + sizeof (int);
1890-
UDP_bytes_in_packets = UDP_nr_of_packets + sizeof (int);
1891-
IP_nr_of_packets = UDP_bytes_in_packets + sizeof (unsigned long);
1892-
DESC_LEN = IP_nr_of_packets + sizeof (int);
1885+
running_connections = (struct shared_conn_data *)((char *)logged_connections + sizeof(struct shared_logged_conn));
1886+
TCP_nr_of_packets = (int *)((char *)running_connections + sizeof(struct shared_conn_data) * CONNECTION_CAPACITY);
1887+
TCP_bytes_in_packets = (unsigned long *)((char *)TCP_nr_of_packets + sizeof(int));
1888+
ICMP_nr_of_packets = (unsigned int *)((char *)TCP_bytes_in_packets + sizeof(unsigned long));
1889+
UDP_nr_of_packets = (unsigned int *)(ICMP_nr_of_packets + 1);
1890+
UDP_bytes_in_packets = (unsigned long *)((char *)UDP_nr_of_packets + sizeof(unsigned int));
1891+
IP_nr_of_packets = (unsigned int *)((char *)UDP_bytes_in_packets + sizeof(unsigned long));
1892+
DESC_LEN = (int *)(IP_nr_of_packets + 1);
18931893
clear_shared_mem (0);
18941894

18951895
*DESC_LEN = 10; /* not necessary, but for security (eliminate very unlikely races) */

0 commit comments

Comments
 (0)