@@ -42,7 +42,7 @@ static bool llmnr_ipv6 = false;
4242/* Host name in DNS name format (length octet + name + 0 byte) */
4343#define LLMNR_LABEL_LEN (LLMNR_LABEL_MAX_SIZE + 2)
4444static char * * llmnr_hostnames = NULL ;
45- int llmnr_hostname_count = 0 ;
45+ size_t llmnr_hostname_count = 0 ;
4646
4747static void set_hostname (int entry_index , const char * hostname )
4848{
@@ -51,7 +51,7 @@ static void set_hostname(int entry_index, const char *hostname)
5151 llmnr_hostnames [entry_index ] = xzalloc (LLMNR_LABEL_LEN );
5252 entry_llmnr_hostname = llmnr_hostnames [entry_index ];
5353
54- entry_llmnr_hostname [0 ] = strlen (hostname );
54+ entry_llmnr_hostname [0 ] = ( uint8_t ) strlen (hostname );
5555 strncpy (& entry_llmnr_hostname [1 ], hostname , LLMNR_LABEL_MAX_SIZE );
5656 entry_llmnr_hostname [LLMNR_LABEL_MAX_SIZE + 1 ] = '\0' ;
5757}
@@ -61,44 +61,45 @@ void llmnr_set_hostname(const char *hostname)
6161 set_hostname (0 , hostname );
6262}
6363
64- void llmnr_init (const char * hostnames [], int hostname_count , bool ipv6 )
64+ void llmnr_init (const char * hostnames [], size_t hostname_count , bool ipv6 )
6565{
66- int name_i = 0 ;
66+ size_t i ;
6767 llmnr_hostname_count = hostname_count ;
6868 llmnr_hostnames = xzalloc (hostname_count );
69- for (; name_i < hostname_count ; ++ name_i ) {
70- set_hostname (name_i , hostnames [name_i ]);
69+ for (i = 0 ; i < hostname_count ; ++ i ) {
70+ set_hostname (i , hostnames [i ]);
7171 }
7272 llmnr_ipv6 = ipv6 ;
7373}
7474
75- void llmnr_release () {
76- int name_i = 0 ;
77- for (; name_i < llmnr_hostname_count ; ++ name_i ) {
78- free (llmnr_hostnames [name_i ]);
75+ void llmnr_release (void )
76+ {
77+ size_t i ;
78+ for (i = 0 ; i < llmnr_hostname_count ; ++ i ) {
79+ free (llmnr_hostnames [i ]);
7980 }
8081 free (llmnr_hostnames );
8182}
8283
8384/* Return the matched name entry (first byte represents the string length) or NULL */
84- static char * llmnr_name_matches (const uint8_t * query )
85+ static char * llmnr_name_matches (const uint8_t * query )
8586{
86- uint8_t n ;
87- int name_i = 0 ;
87+ uint8_t n ;
88+ size_t i ;
8889
89- for (; name_i < llmnr_hostname_count ; ++ name_i ) {
90- n = llmnr_hostnames [name_i ][0 ];
90+ for ( i = 0 ; i < llmnr_hostname_count ; ++ i ) {
91+ n = llmnr_hostnames [i ][0 ];
9192
92- /* length */
93- if (query [0 ] != n )
94- continue ;
95- /* NULL byte */
96- if (query [1 + n ] != 0 )
97- continue ;
93+ /* length */
94+ if (query [0 ] != n )
95+ continue ;
96+ /* NULL byte */
97+ if (query [1 + n ] != 0 )
98+ continue ;
9899
99- if (strncasecmp ((const char * )& query [1 ], & llmnr_hostnames [name_i ][1 ], n ) == 0 )
100- return llmnr_hostnames [name_i ];
101- }
100+ if (strncasecmp ((const char * ) & query [1 ], & llmnr_hostnames [i ][1 ], n ) == 0 )
101+ return llmnr_hostnames [i ];
102+ }
102103
103104
104105 return NULL ;
@@ -231,7 +232,7 @@ static void llmnr_packet_process(int ifindex, const uint8_t *pktbuf, size_t len,
231232 const uint8_t * query ;
232233 size_t query_len ;
233234 uint8_t name_len ;
234- char * matched_hostname_entry ;
235+ char * matched_hostname_entry ;
235236
236237 /* Query too short? */
237238 if (len < sizeof (struct llmnr_hdr ))
0 commit comments