Compilation fixes

This commit is contained in:
Luca Deri
2022-05-27 17:35:30 +02:00
parent 6d543808ad
commit 7e3d061428
5 changed files with 242 additions and 234 deletions
+2 -2
View File
@@ -203,11 +203,11 @@ static int krb_decode_asn1_blocks_skip(struct ndpi_detection_module_struct *ndpi
static void krb_strncpy_lower(char * const dst, size_t dst_siz, static void krb_strncpy_lower(char * const dst, size_t dst_siz,
char const * const src, size_t src_siz) char const * const src, size_t src_siz)
{ {
int dst_len = ndpi_min(src_siz, dst_siz - 1); int i, dst_len = ndpi_min(src_siz, dst_siz - 1);
dst[dst_len] = '\0'; dst[dst_len] = '\0';
for(int i = 0; i < dst_len; ++i) for(i = 0; i < dst_len; ++i)
{ {
if (ndpi_isprint(src[i]) == 0) if (ndpi_isprint(src[i]) == 0)
{ {
+11 -7
View File
@@ -350,6 +350,7 @@ static gcry_error_t hkdf_expand(int hashalgo, const uint8_t *prk, uint32_t prk_l
gcry_md_hd_t h; gcry_md_hd_t h;
gcry_error_t err; gcry_error_t err;
const unsigned int hash_len = gcry_md_get_algo_dlen(hashalgo); const unsigned int hash_len = gcry_md_get_algo_dlen(hashalgo);
uint32_t offset;
/* Some sanity checks */ /* Some sanity checks */
if(!(out_len > 0 && out_len <= 255 * hash_len) || if(!(out_len > 0 && out_len <= 255 * hash_len) ||
@@ -362,7 +363,7 @@ static gcry_error_t hkdf_expand(int hashalgo, const uint8_t *prk, uint32_t prk_l
return err; return err;
} }
for(uint32_t offset = 0; offset < out_len; offset += hash_len) { for(offset = 0; offset < out_len; offset += hash_len) {
gcry_md_reset(h); gcry_md_reset(h);
gcry_md_setkey(h, prk, prk_len); /* Set PRK */ gcry_md_setkey(h, prk, prk_len); /* Set PRK */
if(offset > 0) { if(offset > 0) {
@@ -712,8 +713,8 @@ static int quic_decrypt_header(const uint8_t *packet_payload,
uint8_t pkn_bytes[4]; uint8_t pkn_bytes[4];
memcpy(pkn_bytes, packet_payload + pn_offset, pkn_len); memcpy(pkn_bytes, packet_payload + pn_offset, pkn_len);
uint32_t pkt_pkn = 0; uint32_t pkt_pkn = 0, i;
for(uint32_t i = 0; i < pkn_len; i++) { for(i = 0; i < pkn_len; i++) {
pkt_pkn |= (uint32_t)(pkn_bytes[i] ^ mask[1 + i]) << (8 * (pkn_len - 1 - i)); pkt_pkn |= (uint32_t)(pkn_bytes[i] ^ mask[1 + i]) << (8 * (pkn_len - 1 - i));
} }
*first_byte = packet0; *first_byte = packet0;
@@ -739,7 +740,7 @@ static void quic_decrypt_message(struct ndpi_detection_module_struct *ndpi_struc
uint8_t nonce[TLS13_AEAD_NONCE_LENGTH]; uint8_t nonce[TLS13_AEAD_NONCE_LENGTH];
uint8_t *buffer; uint8_t *buffer;
uint8_t atag[16]; uint8_t atag[16];
uint32_t buffer_length; uint32_t buffer_length, i;
#ifdef NDPI_ENABLE_DEBUG_MESSAGES #ifdef NDPI_ENABLE_DEBUG_MESSAGES
char buferr[128]; char buferr[128];
#endif #endif
@@ -756,7 +757,7 @@ static void quic_decrypt_message(struct ndpi_detection_module_struct *ndpi_struc
if(!header) if(!header)
return; return;
header[0] = first_byte; header[0] = first_byte;
for(uint32_t i = 0; i < pkn_len; i++) { for( i = 0; i < pkn_len; i++) {
header[header_length - 1 - i] = (uint8_t)(packet_number >> (8 * i)); header[header_length - 1 - i] = (uint8_t)(packet_number >> (8 * i));
} }
@@ -1020,7 +1021,9 @@ static void update_reasm_buf_bitmap(u_int8_t *buffer_bitmap,
if (start_byte == end_byte) if (start_byte == end_byte)
buffer_bitmap[start_byte] |= (((1U << recv_len) - 1U) << start_bit); // fill from bit 'start_bit' until bit 'end_bit', both inclusive buffer_bitmap[start_byte] |= (((1U << recv_len) - 1U) << start_bit); // fill from bit 'start_bit' until bit 'end_bit', both inclusive
else{ else{
for (u_int32_t i = start_byte + 1; i <= end_byte - 1; i++) u_int32_t i;
for (i = start_byte + 1; i <= end_byte - 1; i++)
buffer_bitmap[i] = 0xff; // completely received byte buffer_bitmap[i] = 0xff; // completely received byte
buffer_bitmap[start_byte] |= ~((1U << start_bit) - 1U); // fill from bit 'start_bit' until bit 7, both inclusive buffer_bitmap[start_byte] |= ~((1U << start_bit) - 1U); // fill from bit 'start_bit' until bit 7, both inclusive
buffer_bitmap[end_byte] |= (1U << (end_bit + 1U)) - 1U; // fill from bit 0 until bit 'end_bit', both inclusive buffer_bitmap[end_byte] |= (1U << (end_bit + 1U)) - 1U; // fill from bit 0 until bit 'end_bit', both inclusive
@@ -1032,8 +1035,9 @@ static int is_reasm_buf_complete(const u_int8_t *buffer_bitmap,
{ {
const u_int32_t complete_bytes = buffer_len / 8; const u_int32_t complete_bytes = buffer_len / 8;
const u_int32_t remaining_bits = buffer_len % 8; const u_int32_t remaining_bits = buffer_len % 8;
u_int32_t i;
for(u_int32_t i = 0; i < complete_bytes; i++) for(i = 0; i < complete_bytes; i++)
if (buffer_bitmap[i] != 0xff) if (buffer_bitmap[i] != 0xff)
return 0; return 0;
+3 -1
View File
@@ -165,12 +165,14 @@ void ndpi_search_raknet(struct ndpi_detection_module_struct *ndpi_struct,
case 0x10: /* Connection Request Accepted */ case 0x10: /* Connection Request Accepted */
case 0x13: /* New Incoming Connection */ case 0x13: /* New Incoming Connection */
{ {
size_t i;
ip_addr_offset = 4 + raknet_dissect_ip(packet, 0); ip_addr_offset = 4 + raknet_dissect_ip(packet, 0);
if (op == 0x10) if (op == 0x10)
{ {
ip_addr_offset += 2; // System Index ip_addr_offset += 2; // System Index
} }
for (size_t i = 0; i < 10; ++i) for (i = 0; i < 10; ++i)
{ {
ip_addr_offset += 3 + raknet_dissect_ip(packet, ip_addr_offset); ip_addr_offset += 3 + raknet_dissect_ip(packet, ip_addr_offset);
} }
+2 -2
View File
@@ -66,8 +66,8 @@ void ndpi_search_tftp(struct ndpi_detection_module_struct
{ {
char const * const possible_modes[] = { "netascii", "octet", "mail" }; char const * const possible_modes[] = { "netascii", "octet", "mail" };
uint8_t mode_found = 0; uint8_t mode_found = 0, mode_idx;
for (uint8_t mode_idx = 0; mode_idx < sizeof(possible_modes) / sizeof(possible_modes[0]); ++mode_idx) for(mode_idx = 0; mode_idx < sizeof(possible_modes) / sizeof(possible_modes[0]); ++mode_idx)
{ {
size_t const mode_len = strlen(possible_modes[mode_idx]); size_t const mode_len = strlen(possible_modes[mode_idx]);
+5 -3
View File
@@ -91,7 +91,7 @@ union ja3_info {
$ shasum -a 1 www.grc.com.bin $ shasum -a 1 www.grc.com.bin
159a76..... 159a76.....
*/ */
#define NDPI_MAX_TLS_REQUEST_SIZE 10000 #define NDPI_MAX_TLS_REQUEST_SIZE 10000
#define TLS_THRESHOLD 34387200 /* Threshold for certificate validity */ #define TLS_THRESHOLD 34387200 /* Threshold for certificate validity */
@@ -231,7 +231,7 @@ static void cleanupServerName(char *buffer, u_int buffer_len) {
-1: error (buffer too short) -1: error (buffer too short)
0: OK but buffer is not human readeable (so something went wrong) 0: OK but buffer is not human readeable (so something went wrong)
1: OK 1: OK
*/ */
static int extractRDNSequence(struct ndpi_packet_struct *packet, static int extractRDNSequence(struct ndpi_packet_struct *packet,
u_int offset, char *buffer, u_int buffer_len, u_int offset, char *buffer, u_int buffer_len,
char *rdnSeqBuf, u_int *rdnSeqBuf_offset, char *rdnSeqBuf, u_int *rdnSeqBuf_offset,
@@ -1258,7 +1258,9 @@ static void checkExtensions(struct ndpi_detection_module_struct *ndpi_struct,
if(extension_id > 59 && extension_id != 65281) if(extension_id > 59 && extension_id != 65281)
{ {
u_int8_t extension_found = 0; u_int8_t extension_found = 0;
for (size_t i = 0; i < allowed_non_iana_extensions_size; ++i) size_t i;
for (i = 0; i < allowed_non_iana_extensions_size; ++i)
{ {
if(allowed_non_iana_extensions[i] == extension_id) if(allowed_non_iana_extensions[i] == extension_id)
{ {