Fixed msys2 build warnings and re-activated CI Mingw64 build.
* Removed Visual Studio leftovers. Maintaining an autotools project with VS integration requires some additional overhead. Signed-off-by: Toni Uhlig <matzeton@googlemail.com> Signed-off-by: lns <matzeton@googlemail.com>
This commit is contained in:
@@ -330,10 +330,6 @@ static inline u_int64_t get_u_int64_t(const u_int8_t* X, int O)
|
||||
/* define memory callback function */
|
||||
#define match_first_bytes(payload,st) (memcmp((payload),(st),(sizeof(st)-1))==0)
|
||||
|
||||
#if defined(WIN32) && !defined(snprintf)
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
#undef strtok_r
|
||||
#define strtok_r strtok_s
|
||||
|
||||
@@ -24,10 +24,6 @@
|
||||
#ifndef __NDPI_INCLUDES_OPENBSD_H__
|
||||
#define __NDPI_INCLUDES_OPENBSD_H__
|
||||
|
||||
#ifndef IPPROTO_SCTP
|
||||
#define IPPROTO_SCTP 132
|
||||
#endif /* IPPROTO_SCTP */
|
||||
|
||||
#include <net/bpf.h>
|
||||
|
||||
typedef struct bpf_timeval pkt_timeval;
|
||||
|
||||
@@ -32,4 +32,9 @@ extern u_int8_t ndpi_ends_with(char *str, char *ends);
|
||||
((ch) >= '[' && (ch) <= '`') || \
|
||||
((ch) >= '{' && (ch) <= '~'))
|
||||
|
||||
#ifndef NDPI_CFFI_PREPROCESSING
|
||||
int ndpi_vsnprintf(char * str, size_t size, char const * format, va_list va_args);
|
||||
int ndpi_snprintf(char * str, size_t size, char const * format, ...);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -47,18 +47,12 @@
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#define _WS2TCPIP_H_ /* Avoid compilation problems */
|
||||
|
||||
#define IPVERSION 4 /* on *nix it is defined in netinet/ip.h */
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))
|
||||
#endif
|
||||
|
||||
#ifndef IPPROTO_SCTP
|
||||
#define IPPROTO_SCTP 132
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
#undef gettimeofday
|
||||
#define gettimeofday mingw_gettimeofday
|
||||
|
||||
+4
-1
@@ -14,7 +14,10 @@ RANLIB = @RANLIB@
|
||||
prefix = @prefix@
|
||||
libdir = ${prefix}/lib
|
||||
includedir = ${prefix}/include/ndpi
|
||||
CFLAGS += -fPIC -DPIC -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION @CFLAGS@ @CUSTOM_NDPI@
|
||||
ifneq ($(OS),Windows_NT)
|
||||
CFLAGS += -fPIC -DPIC
|
||||
endif
|
||||
CFLAGS += -I../include -Ithird_party/include -DNDPI_LIB_COMPILATION @CFLAGS@ @CUSTOM_NDPI@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @ADDITIONAL_LIBS@ @LIBS@
|
||||
|
||||
|
||||
@@ -516,7 +516,7 @@ char* ndpi_print_bin(struct ndpi_bin *b, u_int8_t normalize_first, char *out_buf
|
||||
switch(b->family) {
|
||||
case ndpi_bin_family8:
|
||||
for(i=0; i<b->num_bins; i++) {
|
||||
int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins8[i]);
|
||||
int rc = ndpi_snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins8[i]);
|
||||
|
||||
if(rc < 0) break;
|
||||
len += rc;
|
||||
@@ -525,7 +525,7 @@ char* ndpi_print_bin(struct ndpi_bin *b, u_int8_t normalize_first, char *out_buf
|
||||
|
||||
case ndpi_bin_family16:
|
||||
for(i=0; i<b->num_bins; i++) {
|
||||
int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins16[i]);
|
||||
int rc = ndpi_snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins16[i]);
|
||||
|
||||
if(rc < 0) break;
|
||||
len += rc;
|
||||
@@ -534,7 +534,7 @@ char* ndpi_print_bin(struct ndpi_bin *b, u_int8_t normalize_first, char *out_buf
|
||||
|
||||
case ndpi_bin_family32:
|
||||
for(i=0; i<b->num_bins; i++) {
|
||||
int rc = snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins32[i]);
|
||||
int rc = ndpi_snprintf(&out_buf[len], out_buf_len-len, "%s%u", (i > 0) ? "," : "", b->u.bins32[i]);
|
||||
|
||||
if(rc < 0) break;
|
||||
len += rc;
|
||||
|
||||
@@ -696,5 +696,5 @@ ndpi_log_timestamp(char *log_ts, uint32_t log_ts_len)
|
||||
localtime_r(&nowtime, &nowtm_r);
|
||||
#endif
|
||||
strftime(tmbuf, NDPI_TIMESTAMP_LEN, "%H:%M:%S", &nowtm_r);
|
||||
snprintf(log_ts, log_ts_len, "%s.%06ld", tmbuf, (long)tv.tv_usec);
|
||||
ndpi_snprintf(log_ts, log_ts_len, "%s.%06ld", tmbuf, (long)tv.tv_usec);
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ static int ndpi_community_id_finalize_and_compute_hash(u_int8_t *comm_buf, u_int
|
||||
switch(l4_proto) {
|
||||
case IPPROTO_ICMP:
|
||||
case IPPROTO_ICMPV6:
|
||||
case IPPROTO_SCTP:
|
||||
case NDPI_SCTP_PROTOCOL_TYPE:
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_TCP:
|
||||
off += ndpi_community_id_buf_copy(&comm_buf[off], &src_port, sizeof(src_port));
|
||||
@@ -285,7 +285,7 @@ int ndpi_flowv4_flow_hash(u_int8_t l4_proto, u_int32_t src_ip, u_int32_t dst_ip,
|
||||
src_port = icmp_type;
|
||||
dst_port = ndpi_community_id_icmp_type_to_code_v4(icmp_type, icmp_code, &icmp_one_way);
|
||||
break;
|
||||
case IPPROTO_SCTP:
|
||||
case NDPI_SCTP_PROTOCOL_TYPE:
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_TCP:
|
||||
/* src/dst port ok */
|
||||
@@ -344,7 +344,7 @@ int ndpi_flowv6_flow_hash(u_int8_t l4_proto, struct ndpi_in6_addr *src_ip, struc
|
||||
src_port = icmp_type;
|
||||
dst_port = ndpi_community_id_icmp_type_to_code_v6(icmp_type, icmp_code, &icmp_one_way);
|
||||
break;
|
||||
case IPPROTO_SCTP:
|
||||
case NDPI_SCTP_PROTOCOL_TYPE:
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_TCP:
|
||||
/* src/dst port ok */
|
||||
|
||||
+28
-26
@@ -173,7 +173,7 @@ static inline uint8_t flow_is_proto(struct ndpi_flow_struct *flow, u_int16_t p)
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
static u_int32_t ndpi_tot_allocated_memory;
|
||||
static volatile long int ndpi_tot_allocated_memory;
|
||||
|
||||
/* ****************************************** */
|
||||
|
||||
@@ -2258,7 +2258,7 @@ void ndpi_debug_printf(unsigned int proto, struct ndpi_detection_module_struct *
|
||||
!NDPI_ISSET(&ndpi_str->debug_bitmask, proto))
|
||||
return;
|
||||
va_start(args, format);
|
||||
vsnprintf(str, sizeof(str) - 1, format, args);
|
||||
ndpi_vsnprintf(str, sizeof(str) - 1, format, args);
|
||||
va_end(args);
|
||||
|
||||
if(ndpi_str != NULL) {
|
||||
@@ -2576,7 +2576,7 @@ struct ndpi_detection_module_struct *ndpi_init_detection_module(ndpi_init_prefs
|
||||
}
|
||||
|
||||
for(i = 0; i < NUM_CUSTOM_CATEGORIES; i++)
|
||||
snprintf(ndpi_str->custom_category_labels[i], CUSTOM_CATEGORY_LABEL_LEN, "User custom category %u",
|
||||
ndpi_snprintf(ndpi_str->custom_category_labels[i], CUSTOM_CATEGORY_LABEL_LEN, "User custom category %u",
|
||||
(unsigned int) (i + 1));
|
||||
|
||||
return(ndpi_str);
|
||||
@@ -3250,7 +3250,7 @@ int ndpi_add_trusted_issuer_dn(struct ndpi_detection_module_struct *ndpi_str, ch
|
||||
if(dn[0] == '"') {
|
||||
char buf[128], *quote;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s", &dn[1]);
|
||||
ndpi_snprintf(buf, sizeof(buf), "%s", &dn[1]);
|
||||
|
||||
if((quote = strchr(buf, '"')) != NULL)
|
||||
quote[0] = '\0';
|
||||
@@ -3281,7 +3281,7 @@ int ndpi_handle_rule(struct ndpi_detection_module_struct *ndpi_str, char *rule,
|
||||
/* This looks like a mask rule or an invalid rule */
|
||||
char _rule[256], *rule_type, *key;
|
||||
|
||||
snprintf(_rule, sizeof(_rule), "%s", rule);
|
||||
ndpi_snprintf(_rule, sizeof(_rule), "%s", rule);
|
||||
rule_type = strtok(rule, ":");
|
||||
|
||||
if(!rule_type) {
|
||||
@@ -6854,13 +6854,15 @@ char *ndpi_get_ip_string(const ndpi_ip_addr_t *ip, char *buf, u_int buf_len) {
|
||||
const u_int8_t *a = (const u_int8_t *) &ip->ipv4;
|
||||
|
||||
if(ndpi_is_ipv6(ip)) {
|
||||
if(inet_ntop(AF_INET6, &ip->ipv6.u6_addr, buf, buf_len) == NULL)
|
||||
struct in6_addr addr = *(struct in6_addr *)&ip->ipv6.u6_addr;
|
||||
|
||||
if(inet_ntop(AF_INET6, &addr, buf, buf_len) == NULL)
|
||||
buf[0] = '\0';
|
||||
|
||||
return(buf);
|
||||
}
|
||||
|
||||
snprintf(buf, buf_len, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]);
|
||||
ndpi_snprintf(buf, buf_len, "%u.%u.%u.%u", a[0], a[1], a[2], a[3]);
|
||||
|
||||
return(buf);
|
||||
}
|
||||
@@ -7010,11 +7012,11 @@ char *ndpi_protocol2id(struct ndpi_detection_module_struct *ndpi_str,
|
||||
ndpi_protocol proto, char *buf, u_int buf_len) {
|
||||
if((proto.master_protocol != NDPI_PROTOCOL_UNKNOWN) && (proto.master_protocol != proto.app_protocol)) {
|
||||
if(proto.app_protocol != NDPI_PROTOCOL_UNKNOWN)
|
||||
snprintf(buf, buf_len, "%u.%u", proto.master_protocol, proto.app_protocol);
|
||||
ndpi_snprintf(buf, buf_len, "%u.%u", proto.master_protocol, proto.app_protocol);
|
||||
else
|
||||
snprintf(buf, buf_len, "%u", proto.master_protocol);
|
||||
ndpi_snprintf(buf, buf_len, "%u", proto.master_protocol);
|
||||
} else
|
||||
snprintf(buf, buf_len, "%u", proto.app_protocol);
|
||||
ndpi_snprintf(buf, buf_len, "%u", proto.app_protocol);
|
||||
|
||||
return(buf);
|
||||
}
|
||||
@@ -7025,12 +7027,12 @@ char *ndpi_protocol2name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
ndpi_protocol proto, char *buf, u_int buf_len) {
|
||||
if((proto.master_protocol != NDPI_PROTOCOL_UNKNOWN) && (proto.master_protocol != proto.app_protocol)) {
|
||||
if(proto.app_protocol != NDPI_PROTOCOL_UNKNOWN)
|
||||
snprintf(buf, buf_len, "%s.%s", ndpi_get_proto_name(ndpi_str, proto.master_protocol),
|
||||
ndpi_snprintf(buf, buf_len, "%s.%s", ndpi_get_proto_name(ndpi_str, proto.master_protocol),
|
||||
ndpi_get_proto_name(ndpi_str, proto.app_protocol));
|
||||
else
|
||||
snprintf(buf, buf_len, "%s", ndpi_get_proto_name(ndpi_str, proto.master_protocol));
|
||||
ndpi_snprintf(buf, buf_len, "%s", ndpi_get_proto_name(ndpi_str, proto.master_protocol));
|
||||
} else
|
||||
snprintf(buf, buf_len, "%s", ndpi_get_proto_name(ndpi_str, proto.app_protocol));
|
||||
ndpi_snprintf(buf, buf_len, "%s", ndpi_get_proto_name(ndpi_str, proto.app_protocol));
|
||||
|
||||
return(buf);
|
||||
}
|
||||
@@ -7063,23 +7065,23 @@ void ndpi_category_set_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
|
||||
switch(category) {
|
||||
case NDPI_PROTOCOL_CATEGORY_CUSTOM_1:
|
||||
snprintf(ndpi_str->custom_category_labels[0], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
ndpi_snprintf(ndpi_str->custom_category_labels[0], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
break;
|
||||
|
||||
case NDPI_PROTOCOL_CATEGORY_CUSTOM_2:
|
||||
snprintf(ndpi_str->custom_category_labels[1], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
ndpi_snprintf(ndpi_str->custom_category_labels[1], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
break;
|
||||
|
||||
case NDPI_PROTOCOL_CATEGORY_CUSTOM_3:
|
||||
snprintf(ndpi_str->custom_category_labels[2], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
ndpi_snprintf(ndpi_str->custom_category_labels[2], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
break;
|
||||
|
||||
case NDPI_PROTOCOL_CATEGORY_CUSTOM_4:
|
||||
snprintf(ndpi_str->custom_category_labels[3], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
ndpi_snprintf(ndpi_str->custom_category_labels[3], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
break;
|
||||
|
||||
case NDPI_PROTOCOL_CATEGORY_CUSTOM_5:
|
||||
snprintf(ndpi_str->custom_category_labels[4], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
ndpi_snprintf(ndpi_str->custom_category_labels[4], CUSTOM_CATEGORY_LABEL_LEN, "%s", name);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -7115,9 +7117,9 @@ const char *ndpi_category_get_name(struct ndpi_detection_module_struct *ndpi_str
|
||||
static char b[24];
|
||||
|
||||
if(!ndpi_str)
|
||||
snprintf(b, sizeof(b), "NULL nDPI");
|
||||
ndpi_snprintf(b, sizeof(b), "NULL nDPI");
|
||||
else
|
||||
snprintf(b, sizeof(b), "Invalid category %d", (int) category);
|
||||
ndpi_snprintf(b, sizeof(b), "Invalid category %d", (int) category);
|
||||
return(b);
|
||||
}
|
||||
|
||||
@@ -8064,7 +8066,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
if(ndpi_match_string_subprotocol(ndpi_str, name, strlen(name), &ret_match) > 0)
|
||||
return(0); /* Ignore DGA for known domain names */
|
||||
|
||||
if(isdigit(name[0])) {
|
||||
if(isdigit((int)name[0])) {
|
||||
struct in_addr ip_addr;
|
||||
|
||||
ip_addr.s_addr = inet_addr(name);
|
||||
@@ -8087,7 +8089,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
char tmp[128], *word, *tok_tmp;
|
||||
u_int i, j, max_tmp_len = sizeof(tmp)-1;
|
||||
|
||||
len = snprintf(tmp, max_tmp_len, "%s", name);
|
||||
len = ndpi_snprintf(tmp, max_tmp_len, "%s", name);
|
||||
if(len < 0) {
|
||||
|
||||
if(ndpi_verbose_dga_detection)
|
||||
@@ -8103,7 +8105,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
if(tmp[j] == '.') {
|
||||
num_dots++;
|
||||
} else if(num_dots == 0) {
|
||||
if(!isdigit(tmp[j]))
|
||||
if(!isdigit((int)tmp[j]))
|
||||
first_element_is_numeric = 0;
|
||||
}
|
||||
|
||||
@@ -8116,10 +8118,10 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
} else
|
||||
num_char_repetitions = 1, last_char = tmp[j];
|
||||
|
||||
if(isdigit(tmp[j])) {
|
||||
if(isdigit((int)tmp[j])) {
|
||||
num_digits++;
|
||||
|
||||
if(((j+2)<(u_int)len) && isdigit(tmp[j+1]) && (tmp[j+2] == '.')) {
|
||||
if(((j+2)<(u_int)len) && isdigit((int)tmp[j+1]) && (tmp[j+2] == '.')) {
|
||||
/* Check if there are too many digits */
|
||||
if(num_digits < 4)
|
||||
return(0); /* Double digits */
|
||||
@@ -8218,7 +8220,7 @@ int ndpi_check_dga_name(struct ndpi_detection_module_struct *ndpi_str,
|
||||
trigram_char_skip = 0;
|
||||
|
||||
for(i = 0; word[i+1] != '\0'; i++) {
|
||||
if(isdigit(word[i]))
|
||||
if(isdigit((int)word[i]))
|
||||
num_consecutive_digits++;
|
||||
else {
|
||||
if((num_word == 1) && (num_consecutive_digits > max_num_consecutive_digits_first_word))
|
||||
|
||||
+49
-49
@@ -40,8 +40,8 @@
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#define NDPI_I64_FORMAT "%" PRId64
|
||||
#define NDPI_U64_FORMAT "%" PRIu64
|
||||
#define NDPI_I64_FORMAT "%I64d"
|
||||
#define NDPI_U64_FORMAT "%I64u"
|
||||
#else
|
||||
#define NDPI_I64_FORMAT "%lld"
|
||||
#define NDPI_U64_FORMAT "%llu"
|
||||
@@ -78,7 +78,7 @@ static int ndpi_is_number(const char *str, u_int32_t str_len) {
|
||||
unsigned int i;
|
||||
|
||||
for(i = 0; i < str_len; i++)
|
||||
if(!isdigit(str[i])) return(0);
|
||||
if(!isdigit((int)str[i])) return(0);
|
||||
|
||||
return(1);
|
||||
}
|
||||
@@ -146,8 +146,8 @@ static int ndpi_json_string_escape(const char *src, int src_len, char *dst, int
|
||||
|
||||
#if UNUSED
|
||||
/*
|
||||
* Similar to snprintf, this returns the number of bytes actually written
|
||||
* in any case (unlike snprintf which returns, if the output is truncated,
|
||||
* Similar to ndpi_snprintf, this returns the number of bytes actually written
|
||||
* in any case (unlike ndpi_snprintf which returns, if the output is truncated,
|
||||
* the number of bytes which *would have been* written, and a negative
|
||||
* value on failures)
|
||||
*/
|
||||
@@ -156,7 +156,7 @@ static inline int ndpi_snappend(char *buf, size_t size, const char *fmt, ...) {
|
||||
va_list va;
|
||||
|
||||
va_start(va, fmt);
|
||||
wlen = snprintf(buf, size, fmt, va);
|
||||
wlen = ndpi_snprintf(buf, size, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
if (wlen < 0)
|
||||
@@ -182,7 +182,7 @@ void ndpi_reset_serializer(ndpi_serializer *_serializer) {
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
|
||||
/* Note: please keep a space at the beginning as it is used for arrays when an end-of-record is used */
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, " {}");
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, " {}");
|
||||
} else if(serializer->fmt == ndpi_serialization_format_csv) {
|
||||
serializer->status.header.size_used = 0;
|
||||
serializer->status.buffer.size_used = 0;
|
||||
@@ -307,7 +307,7 @@ static inline int ndpi_serializer_header_uint32(ndpi_private_serializer *seriali
|
||||
if (room < 0)
|
||||
return(-1);
|
||||
|
||||
serializer->status.header.size_used += snprintf((char *) &serializer->header.data[serializer->status.header.size_used],
|
||||
serializer->status.header.size_used += ndpi_snprintf((char *) &serializer->header.data[serializer->status.header.size_used],
|
||||
room, "%s%u", (serializer->status.header.size_used > 0) ? serializer->csv_separator : "", key);
|
||||
|
||||
return(0);
|
||||
@@ -657,7 +657,7 @@ int ndpi_serialize_end_of_record(ndpi_serializer *_serializer) {
|
||||
} else if(serializer->fmt == ndpi_serialization_format_json) {
|
||||
if(!(serializer->status.flags & NDPI_SERIALIZER_STATUS_ARRAY)) {
|
||||
serializer->buffer.data[0] = '[';
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "]");
|
||||
}
|
||||
|
||||
@@ -777,13 +777,13 @@ int ndpi_serialize_uint32_uint32(ndpi_serializer *_serializer,
|
||||
ndpi_serialize_json_pre(_serializer);
|
||||
|
||||
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "\"%u\":", key);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "%u", value);
|
||||
|
||||
@@ -792,7 +792,7 @@ int ndpi_serialize_uint32_uint32(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
"%u", value);
|
||||
} else {
|
||||
@@ -845,13 +845,13 @@ int ndpi_serialize_uint32_uint64(ndpi_serializer *_serializer,
|
||||
ndpi_serialize_json_pre(_serializer);
|
||||
|
||||
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
"\"%u\":", key);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
NDPI_U64_FORMAT, (unsigned long long)value);
|
||||
|
||||
@@ -860,7 +860,7 @@ int ndpi_serialize_uint32_uint64(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
NDPI_U64_FORMAT, (unsigned long long)value);
|
||||
} else {
|
||||
@@ -909,13 +909,13 @@ int ndpi_serialize_uint32_int32(ndpi_serializer *_serializer,
|
||||
ndpi_serialize_json_pre(_serializer);
|
||||
|
||||
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "\"%u\":", key);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "%d", value);
|
||||
|
||||
@@ -924,7 +924,7 @@ int ndpi_serialize_uint32_int32(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
"%d", value);
|
||||
} else {
|
||||
@@ -977,13 +977,13 @@ int ndpi_serialize_uint32_int64(ndpi_serializer *_serializer,
|
||||
ndpi_serialize_json_pre(_serializer);
|
||||
|
||||
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "\"%u\":", key);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, NDPI_I64_FORMAT, (long long int)value);
|
||||
|
||||
@@ -992,7 +992,7 @@ int ndpi_serialize_uint32_int64(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
NDPI_I64_FORMAT, (long long int)value);
|
||||
}
|
||||
@@ -1043,18 +1043,18 @@ int ndpi_serialize_uint32_float(ndpi_serializer *_serializer,
|
||||
ndpi_serialize_json_pre(_serializer);
|
||||
|
||||
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "\"%u\":", key);
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "\"%u\":", key);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
|
||||
|
||||
ndpi_serialize_json_post(_serializer);
|
||||
} else if(serializer->fmt == ndpi_serialization_format_csv) {
|
||||
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
|
||||
|
||||
} else {
|
||||
ndpi_serialization_type kt;
|
||||
@@ -1099,7 +1099,7 @@ static int ndpi_serialize_uint32_binary(ndpi_serializer *_serializer,
|
||||
ndpi_serialize_json_pre(_serializer);
|
||||
|
||||
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "\"%u\":", key);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
@@ -1111,7 +1111,7 @@ static int ndpi_serialize_uint32_binary(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
"%s", value);
|
||||
} else {
|
||||
@@ -1162,13 +1162,13 @@ int ndpi_serialize_uint32_boolean(ndpi_serializer *_serializer,
|
||||
ndpi_serialize_json_pre(_serializer);
|
||||
|
||||
if (!(serializer->status.flags & NDPI_SERIALIZER_STATUS_LIST)) {
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "\"%u\":", key);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "%s", value ? "true" : "false");
|
||||
|
||||
@@ -1177,7 +1177,7 @@ int ndpi_serialize_uint32_boolean(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_uint32(serializer, key) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
"%s", value ? "true" : "false");
|
||||
}
|
||||
@@ -1226,7 +1226,7 @@ int ndpi_serialize_binary_int32(ndpi_serializer *_serializer,
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "%d", value);
|
||||
|
||||
ndpi_serialize_json_post(_serializer);
|
||||
@@ -1234,7 +1234,7 @@ int ndpi_serialize_binary_int32(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
"%d", value);
|
||||
} else {
|
||||
@@ -1286,7 +1286,7 @@ int ndpi_serialize_string_int32(ndpi_serializer *_serializer,
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
needed--;
|
||||
|
||||
rc = snprintf((char*)&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
rc = ndpi_snprintf((char*)&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
needed, "%u", value);
|
||||
|
||||
if(rc > 0)
|
||||
@@ -1338,7 +1338,7 @@ int ndpi_serialize_binary_int64(ndpi_serializer *_serializer,
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
NDPI_I64_FORMAT, (long long int)value);
|
||||
|
||||
@@ -1347,7 +1347,7 @@ int ndpi_serialize_binary_int64(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
NDPI_I64_FORMAT, (long long int)value);
|
||||
} else {
|
||||
if ((value & 0xFFFFFFFF) == value) {
|
||||
@@ -1385,7 +1385,7 @@ int ndpi_serialize_binary_uint32(ndpi_serializer *_serializer,
|
||||
u_int16_t needed;
|
||||
char _value[16];
|
||||
|
||||
snprintf(_value, sizeof(_value), "%u", value);
|
||||
ndpi_snprintf(_value, sizeof(_value), "%u", value);
|
||||
needed = strlen(_value) + 1 /* CVS separator */;
|
||||
|
||||
if(buff_diff < needed) {
|
||||
@@ -1439,7 +1439,7 @@ int ndpi_serialize_binary_uint32(ndpi_serializer *_serializer,
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used],
|
||||
buff_diff, "%u", value);
|
||||
|
||||
@@ -1448,7 +1448,7 @@ int ndpi_serialize_binary_uint32(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
"%u", value);
|
||||
} else {
|
||||
@@ -1495,7 +1495,7 @@ int ndpi_serialize_string_uint32_format(ndpi_serializer *_serializer,
|
||||
} else {
|
||||
char buf[16];
|
||||
|
||||
snprintf(buf, sizeof(buf), format, value);
|
||||
ndpi_snprintf(buf, sizeof(buf), format, value);
|
||||
return(ndpi_serialize_string_string(_serializer, key, buf));
|
||||
}
|
||||
}
|
||||
@@ -1541,7 +1541,7 @@ int ndpi_serialize_binary_uint64(ndpi_serializer *_serializer,
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
NDPI_U64_FORMAT, (unsigned long long)value);
|
||||
|
||||
@@ -1550,7 +1550,7 @@ int ndpi_serialize_binary_uint64(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
NDPI_U64_FORMAT, (unsigned long long)value);
|
||||
} else {
|
||||
@@ -1616,14 +1616,14 @@ int ndpi_serialize_binary_float(ndpi_serializer *_serializer,
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
|
||||
|
||||
ndpi_serialize_json_post(_serializer);
|
||||
} else if(serializer->fmt == ndpi_serialization_format_csv) {
|
||||
if (ndpi_serializer_header_string(serializer, key, klen) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, format, value);
|
||||
} else {
|
||||
serializer->buffer.data[serializer->status.buffer.size_used++] = (ndpi_serialization_string << 4) | ndpi_serialization_float;
|
||||
|
||||
@@ -1688,7 +1688,7 @@ static int ndpi_serialize_binary_raw(ndpi_serializer *_serializer,
|
||||
serializer->status.buffer.size_used += ndpi_json_string_escape(value, vlen,
|
||||
(char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff);
|
||||
else {
|
||||
//serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, value, vlen);
|
||||
//serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, value, vlen);
|
||||
memcpy(&serializer->buffer.data[serializer->status.buffer.size_used], value, vlen);
|
||||
serializer->status.buffer.size_used += vlen;
|
||||
}
|
||||
@@ -1699,7 +1699,7 @@ static int ndpi_serialize_binary_raw(ndpi_serializer *_serializer,
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
|
||||
//serializer->status.buffer.size_used += snprintf((char *)
|
||||
//serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
// &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "%s", value);
|
||||
memcpy(&serializer->buffer.data[serializer->status.buffer.size_used], value, vlen);
|
||||
serializer->status.buffer.size_used += vlen;
|
||||
@@ -1833,7 +1833,7 @@ int ndpi_serialize_binary_boolean(ndpi_serializer *_serializer,
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
}
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *)
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *)
|
||||
&serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, "%s",
|
||||
value ? "true" : "false");
|
||||
|
||||
@@ -1842,7 +1842,7 @@ int ndpi_serialize_binary_boolean(ndpi_serializer *_serializer,
|
||||
if (ndpi_serializer_header_string(serializer, key, strlen(key)) < 0) return(-1);
|
||||
ndpi_serialize_csv_pre(serializer);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff,
|
||||
"%s", value ? "true" : "false");
|
||||
}
|
||||
|
||||
@@ -1885,7 +1885,7 @@ int ndpi_serialize_start_of_list_binary(ndpi_serializer *_serializer,
|
||||
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, ": [");
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, ": [");
|
||||
|
||||
serializer->status.flags |= NDPI_SERIALIZER_STATUS_LIST | NDPI_SERIALIZER_STATUS_SOL;
|
||||
|
||||
@@ -1957,7 +1957,7 @@ int ndpi_serialize_start_of_block_binary(ndpi_serializer *_serializer,
|
||||
serializer->status.buffer.size_used += ndpi_json_string_escape(key, klen,
|
||||
(char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff);
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
serializer->status.buffer.size_used += snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, ": {");
|
||||
serializer->status.buffer.size_used += ndpi_snprintf((char *) &serializer->buffer.data[serializer->status.buffer.size_used], buff_diff, ": {");
|
||||
buff_diff = serializer->buffer.size - serializer->status.buffer.size_used;
|
||||
ndpi_serialize_json_post(_serializer);
|
||||
|
||||
@@ -1986,7 +1986,7 @@ int ndpi_serialize_start_of_block(ndpi_serializer *_serializer,
|
||||
/* Serialize start of nested block with a numeric key */
|
||||
int ndpi_serialize_start_of_block_uint32(ndpi_serializer *_serializer, u_int32_t key) {
|
||||
char buf[11];
|
||||
int written = snprintf(buf, sizeof(buf), "%u", key);
|
||||
int written = ndpi_snprintf(buf, sizeof(buf), "%u", key);
|
||||
|
||||
if (written <= 0 || written == sizeof(buf))
|
||||
{
|
||||
|
||||
+38
-5
@@ -733,7 +733,7 @@ const char* ndpi_cipher2str(u_int32_t cipher) {
|
||||
{
|
||||
static char buf[8];
|
||||
|
||||
snprintf(buf, sizeof(buf), "0X%04X", cipher);
|
||||
ndpi_snprintf(buf, sizeof(buf), "0X%04X", cipher);
|
||||
return(buf);
|
||||
}
|
||||
}
|
||||
@@ -778,7 +778,7 @@ static int ndpi_find_non_eng_bigrams(struct ndpi_detection_module_struct *ndpi_s
|
||||
char *str) {
|
||||
char s[3];
|
||||
|
||||
if((isdigit(str[0]) && isdigit(str[1]))
|
||||
if((isdigit((int)str[0]) && isdigit((int)str[1]))
|
||||
|| ndpi_is_other_char(str[0])
|
||||
|| ndpi_is_other_char(str[1])
|
||||
)
|
||||
@@ -935,7 +935,7 @@ char* ndpi_ssl_version2str(char *buf, int buf_len,
|
||||
if(unknown_tls_version)
|
||||
*unknown_tls_version = 1;
|
||||
|
||||
snprintf(buf, buf_len, "TLS (%04X)", version);
|
||||
ndpi_snprintf(buf, buf_len, "TLS (%04X)", version);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -1415,7 +1415,7 @@ int ndpi_dpi2json(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
if(flow->protos.tls_quic.sha1_certificate_fingerprint[0] != '\0') {
|
||||
for(i=0, off=0; i<20; i++) {
|
||||
int rc = snprintf(&buf[off], sizeof(buf)-off,"%s%02X", (i > 0) ? ":" : "",
|
||||
int rc = ndpi_snprintf(&buf[off], sizeof(buf)-off,"%s%02X", (i > 0) ? ":" : "",
|
||||
flow->protos.tls_quic.sha1_certificate_fingerprint[i] & 0xFF);
|
||||
|
||||
if(rc <= 0) break; else off += rc;
|
||||
@@ -1905,7 +1905,7 @@ const char* ndpi_risk2str(ndpi_risk_enum risk) {
|
||||
break;
|
||||
|
||||
default:
|
||||
snprintf(buf, sizeof(buf), "%d", (int)risk);
|
||||
ndpi_snprintf(buf, sizeof(buf), "%d", (int)risk);
|
||||
return(buf);
|
||||
}
|
||||
}
|
||||
@@ -2433,3 +2433,36 @@ void ndpi_set_tls_cert_expire_days(struct ndpi_detection_module_struct *ndpi_str
|
||||
u_int8_t num_days) {
|
||||
ndpi_str->tls_certificate_expire_in_x_days = num_days;
|
||||
}
|
||||
|
||||
/* ******************************************* */
|
||||
|
||||
int ndpi_vsnprintf(char * str, size_t size, char const * format, va_list va_args)
|
||||
{
|
||||
#ifdef WIN32
|
||||
if (str == NULL || size == 0 || format == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ret = vsnprintf_s(str, size, _TRUNCATE, format, va_args);
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
return size;
|
||||
} else {
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
return vsnprintf(str, size, format, va_args);
|
||||
#endif
|
||||
}
|
||||
|
||||
int ndpi_snprintf(char * str, size_t size, char const * format, ...)
|
||||
{
|
||||
va_list va_args;
|
||||
|
||||
va_start(va_args, format);
|
||||
int ret = ndpi_vsnprintf(str, size, format, va_args);
|
||||
va_end(va_args);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ void ndpi_search_dhcp_udp(struct ndpi_detection_module_struct *ndpi_struct, stru
|
||||
u_int idx, offset = 0;
|
||||
|
||||
for(idx = 0; idx < len && offset < sizeof(flow->protos.dhcp.fingerprint) - 2; idx++) {
|
||||
int rc = snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
|
||||
int rc = ndpi_snprintf((char*)&flow->protos.dhcp.fingerprint[offset],
|
||||
sizeof(flow->protos.dhcp.fingerprint) - offset,
|
||||
"%s%u", (idx > 0) ? "," : "",
|
||||
(unsigned int)dhcp->options[i+2+idx] & 0xFF);
|
||||
|
||||
@@ -200,17 +200,21 @@ static int krb_decode_asn1_blocks_skip(struct ndpi_detection_module_struct *ndpi
|
||||
return length;
|
||||
}
|
||||
|
||||
static void strncpy_lower(char * const dst, size_t dst_siz,
|
||||
char const * const src, size_t src_siz)
|
||||
static void krb_strncpy_lower(char * const dst, size_t dst_siz,
|
||||
char const * const src, size_t src_siz)
|
||||
{
|
||||
int dst_len = ndpi_min(src_siz, dst_siz - 1);
|
||||
|
||||
strncpy(dst, src, dst_len);
|
||||
dst[dst_len] = '\0';
|
||||
|
||||
for(int i = 0; i < dst_len; ++i)
|
||||
{
|
||||
dst[i] = tolower(dst[i]);
|
||||
if (ndpi_isprint(src[i]) == 0)
|
||||
{
|
||||
dst[i] = '?';
|
||||
} else {
|
||||
dst[i] = tolower(src[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,8 +276,8 @@ static int krb_parse(struct ndpi_detection_module_struct * const ndpi_struct,
|
||||
length -= 2;
|
||||
if (flow->protos.kerberos.domain[0] == '\0')
|
||||
{
|
||||
strncpy_lower(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain),
|
||||
text, length);
|
||||
krb_strncpy_lower(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain),
|
||||
text, length);
|
||||
}
|
||||
|
||||
length = krb_decode_asn1_string_type(ndpi_struct, &kasn1_offset, NULL);
|
||||
@@ -312,11 +316,11 @@ static int krb_parse(struct ndpi_detection_module_struct * const ndpi_struct,
|
||||
length -= 2;
|
||||
if (flow->protos.kerberos.hostname[0] == '\0' && text[length - 1] != '$')
|
||||
{
|
||||
strncpy_lower(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname),
|
||||
text, length);
|
||||
krb_strncpy_lower(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname),
|
||||
text, length);
|
||||
} else if (flow->protos.kerberos.username[0] == '\0') {
|
||||
strncpy_lower(flow->protos.kerberos.username, sizeof(flow->protos.kerberos.username),
|
||||
text, length - 1);
|
||||
krb_strncpy_lower(flow->protos.kerberos.username, sizeof(flow->protos.kerberos.username),
|
||||
text, length - 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -532,15 +536,9 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
cname_str[0] = '\0'; // required, because cname_len
|
||||
|
||||
while(++num_cname <= 2) {
|
||||
if(cname_len > sizeof(cname_str)-1)
|
||||
cname_len = sizeof(cname_str)-1;
|
||||
|
||||
if (name_offset + cname_len + 1 >= packet->payload_packet_len)
|
||||
cname_len = 0;
|
||||
else
|
||||
strncpy(cname_str, (char*)&packet->payload[name_offset+1], cname_len);
|
||||
cname_str[cname_len] = '\0';
|
||||
for(i=0; i<cname_len; i++) cname_str[i] = tolower(cname_str[i]);
|
||||
krb_strncpy_lower(cname_str, sizeof(cname_str), (char*)&packet->payload[name_offset+1], cname_len);
|
||||
|
||||
#ifdef KERBEROS_DEBUG
|
||||
printf("[AS-REQ][s/dport: %u/%u][Kerberos Cname][len: %u][%s]\n", sport, dport, cname_len, cname_str);
|
||||
@@ -562,9 +560,9 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
&& (cname_len < sizeof(cname_str))
|
||||
&& (cname_str[cname_len-1] == '$')) {
|
||||
cname_str[cname_len-1] = '\0';
|
||||
snprintf(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname), "%s", cname_str);
|
||||
ndpi_snprintf(flow->protos.kerberos.hostname, sizeof(flow->protos.kerberos.hostname), "%s", cname_str);
|
||||
} else
|
||||
snprintf(flow->protos.kerberos.username, sizeof(flow->protos.kerberos.username), "%s", cname_str);
|
||||
ndpi_snprintf(flow->protos.kerberos.username, sizeof(flow->protos.kerberos.username), "%s", cname_str);
|
||||
|
||||
for(i=0; (i < 14) && (realm_offset < packet->payload_packet_len); i++) {
|
||||
if(packet->payload[realm_offset] != 0x1b)
|
||||
@@ -584,19 +582,13 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if((realm_offset+realm_len) < packet->payload_packet_len) {
|
||||
char realm_str[48];
|
||||
|
||||
if(realm_len > sizeof(realm_str)-1)
|
||||
realm_len = sizeof(realm_str)-1;
|
||||
|
||||
realm_offset += 1;
|
||||
|
||||
strncpy(realm_str, (char*)&packet->payload[realm_offset], realm_len);
|
||||
realm_str[realm_len] = '\0';
|
||||
for(i=0; i<realm_len; i++) realm_str[i] = tolower(realm_str[i]);
|
||||
krb_strncpy_lower(realm_str, sizeof(realm_str), (char*)&packet->payload[realm_offset], realm_len);
|
||||
|
||||
#ifdef KERBEROS_DEBUG
|
||||
printf("[AS-REQ][Kerberos Realm][len: %u][%s]\n", realm_len, realm_str);
|
||||
#endif
|
||||
snprintf(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain), "%s", realm_str);
|
||||
ndpi_snprintf(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain), "%s", realm_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -639,19 +631,13 @@ void ndpi_search_kerberos(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if((realm_len+name_offset) < packet->payload_packet_len) {
|
||||
char realm_str[48];
|
||||
|
||||
if(realm_len > sizeof(realm_str)-1)
|
||||
realm_len = sizeof(realm_str)-1;
|
||||
|
||||
name_offset += 1;
|
||||
|
||||
strncpy(realm_str, (char*)&packet->payload[name_offset], realm_len);
|
||||
realm_str[realm_len] = '\0';
|
||||
for(i=0; i<realm_len; i++) realm_str[i] = tolower(realm_str[i]);
|
||||
krb_strncpy_lower(realm_str, sizeof(realm_str), (char*)&packet->payload[name_offset], realm_len);
|
||||
|
||||
#ifdef KERBEROS_DEBUG
|
||||
printf("[TGS-REQ][s/dport: %u/%u][Kerberos Realm][len: %u][%s]\n", sport, dport, realm_len, realm_str);
|
||||
#endif
|
||||
snprintf(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain), "%s", realm_str);
|
||||
ndpi_snprintf(flow->protos.kerberos.domain, sizeof(flow->protos.kerberos.domain), "%s", realm_str);
|
||||
|
||||
/* If necessary we can decode sname */
|
||||
if(flow->kerberos_buf.pktbuf) {
|
||||
|
||||
@@ -178,7 +178,7 @@ void ndpi_search_mail_imap_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if(user) {
|
||||
char *pwd;
|
||||
|
||||
snprintf(flow->l4.tcp.ftp_imap_pop_smtp.username,
|
||||
ndpi_snprintf(flow->l4.tcp.ftp_imap_pop_smtp.username,
|
||||
sizeof(flow->l4.tcp.ftp_imap_pop_smtp.username),
|
||||
"%s", user);
|
||||
|
||||
@@ -186,7 +186,7 @@ void ndpi_search_mail_imap_tcp(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
|
||||
pwd = strtok_r(NULL, " \"\r\n", &saveptr);
|
||||
if(pwd) {
|
||||
snprintf(flow->l4.tcp.ftp_imap_pop_smtp.password,
|
||||
ndpi_snprintf(flow->l4.tcp.ftp_imap_pop_smtp.password,
|
||||
sizeof(flow->l4.tcp.ftp_imap_pop_smtp.password),
|
||||
"%s", pwd);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ static void ndpi_search_mining_udp(struct ndpi_detection_module_struct *ndpi_str
|
||||
else if(packet->iphv6 && ntohl(packet->iphv6->ip6_dst.u6_addr.u6_addr32[0]) == 0xFF020000)
|
||||
;
|
||||
else {
|
||||
snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
|
||||
ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
|
||||
if(packet->iph) /* TODO: ipv6 */
|
||||
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
|
||||
@@ -96,7 +96,7 @@ static void ndpi_search_mining_tcp(struct ndpi_detection_module_struct *ndpi_str
|
||||
u_int32_t magic = htonl(0xf9beb4d9), magic1 = htonl(0xfabfb5da), *to_match = (u_int32_t*)packet->payload;
|
||||
|
||||
if((*to_match == magic) || (*to_match == magic1)) {
|
||||
snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
|
||||
ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
|
||||
if(packet->iph) /* TODO: ipv6 */
|
||||
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
|
||||
@@ -108,7 +108,7 @@ static void ndpi_search_mining_tcp(struct ndpi_detection_module_struct *ndpi_str
|
||||
&& (packet->payload_packet_len < 600)
|
||||
&& (packet->payload[2] == 0x04)) {
|
||||
if(isEthPort(ntohs(packet->tcp->dest)) /* Ethereum port */) {
|
||||
snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
|
||||
ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
|
||||
if(packet->iph) /* TODO: ipv6 */
|
||||
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
|
||||
@@ -127,7 +127,7 @@ static void ndpi_search_mining_tcp(struct ndpi_detection_module_struct *ndpi_str
|
||||
{ "id": 2, "jsonrpc":"2.0","result":true}
|
||||
{"worker": "", "jsonrpc": "2.0", "params": [], "id": 3, "method": "eth_getWork"}
|
||||
*/
|
||||
snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
|
||||
ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ETH");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
|
||||
if(packet->iph) /* TODO: ipv6 */
|
||||
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
|
||||
@@ -151,7 +151,7 @@ static void ndpi_search_mining_tcp(struct ndpi_detection_module_struct *ndpi_str
|
||||
{"id":1,"jsonrpc":"2.0","error":null,"result":{"id":"479059546883218","job":{"blob":"0606e89883d205a65d8ee78991838a1cf3ec2ebbc5fb1fa43dec5fa1cd2bee4069212a549cd731000000005a88235653097aa3e97ef2ceef4aee610751a828f9be1a0758a78365fb0a4c8c05","job_id":"722134174127131","target":"dc460300"},"status":"OK"}}
|
||||
{"method":"submit","params":{"id":"479059546883218","job_id":"722134174127131","nonce":"98024001","result":"c9be9381a68d533c059d614d961e0534d7d8785dd5c339c2f9596eb95f320100"},"id":1}
|
||||
*/
|
||||
snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ZCash/Monero");
|
||||
ndpi_snprintf(flow->flow_extra_info, sizeof(flow->flow_extra_info), "%s", "ZCash/Monero");
|
||||
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_MINING, NDPI_PROTOCOL_UNKNOWN, NDPI_CONFIDENCE_DPI);
|
||||
if(packet->iph) /* TODO: ipv6 */
|
||||
cacheMiningHostTwins(ndpi_struct, packet->iph->saddr + packet->iph->daddr);
|
||||
|
||||
@@ -99,7 +99,19 @@ static int search_telnet_again(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
for(i=0; i<packet->payload_packet_len; i++) {
|
||||
if(packet->packet_direction == 0) /* client -> server */ {
|
||||
if(flow->protos.telnet.character_id < (sizeof(flow->protos.telnet.username)-1))
|
||||
flow->protos.telnet.username[flow->protos.telnet.character_id++] = packet->payload[i];
|
||||
{
|
||||
if (i>=packet->payload_packet_len-2 &&
|
||||
(packet->payload[i] == '\r' || packet->payload[i] == '\n'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (ndpi_isprint(packet->payload[i]) == 0)
|
||||
{
|
||||
flow->protos.telnet.username[flow->protos.telnet.character_id++] = '?';
|
||||
} else {
|
||||
flow->protos.telnet.username[flow->protos.telnet.character_id++] = packet->payload[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+27
-26
@@ -268,7 +268,7 @@ static int extractRDNSequence(struct ndpi_packet_struct *packet,
|
||||
}
|
||||
|
||||
if(is_printable) {
|
||||
int rc = snprintf(&rdnSeqBuf[*rdnSeqBuf_offset],
|
||||
int rc = ndpi_snprintf(&rdnSeqBuf[*rdnSeqBuf_offset],
|
||||
rdnSeqBuf_len-(*rdnSeqBuf_offset),
|
||||
"%s%s=%s", (*rdnSeqBuf_offset > 0) ? ", " : "",
|
||||
label, buffer);
|
||||
@@ -530,13 +530,14 @@ static void processCertificateElements(struct ndpi_detection_module_struct *ndpi
|
||||
|
||||
if(general_name_type == 0x87) {
|
||||
if(len == 4 /* IPv4 */) {
|
||||
snprintf(dNSName, sizeof(dNSName), "%u.%u.%u.%u",
|
||||
ndpi_snprintf(dNSName, sizeof(dNSName), "%u.%u.%u.%u",
|
||||
packet->payload[i] & 0xFF,
|
||||
packet->payload[i+1] & 0xFF,
|
||||
packet->payload[i+2] & 0xFF,
|
||||
packet->payload[i+3] & 0xFF);
|
||||
} else if(len == 16 /* IPv6 */){
|
||||
inet_ntop(AF_INET6, &packet->payload[i], dNSName, sizeof(dNSName));
|
||||
} else if(len == 16 /* IPv6 */) {
|
||||
struct in6_addr addr = *(struct in6_addr *)&packet->payload[i];
|
||||
inet_ntop(AF_INET6, &addr, dNSName, sizeof(dNSName));
|
||||
} else {
|
||||
/* Is that possibile? Better safe than sorry */
|
||||
dNSName[0] = '\0';
|
||||
@@ -1461,7 +1462,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if(flow->protos.tls_quic.alpn != NULL)
|
||||
tlsCheckUncommonALPN(ndpi_struct, flow);
|
||||
|
||||
snprintf(ja3.server.alpn, sizeof(ja3.server.alpn), "%s", alpn_str);
|
||||
ndpi_snprintf(ja3.server.alpn, sizeof(ja3.server.alpn), "%s", alpn_str);
|
||||
|
||||
/* Replace , with - as in JA3 */
|
||||
for(i=0; ja3.server.alpn[i] != '\0'; i++)
|
||||
@@ -1500,36 +1501,36 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
i += 4 + extension_len, offset += 4 + extension_len;
|
||||
} /* for */
|
||||
|
||||
ja3_str_len = snprintf(ja3_str, JA3_STR_LEN, "%u,", ja3.server.tls_handshake_version);
|
||||
ja3_str_len = ndpi_snprintf(ja3_str, JA3_STR_LEN, "%u,", ja3.server.tls_handshake_version);
|
||||
|
||||
for(i=0; (i<ja3.server.num_cipher) && (JA3_STR_LEN > ja3_str_len); i++) {
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u", (i > 0) ? "-" : "", ja3.server.cipher[i]);
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u", (i > 0) ? "-" : "", ja3.server.cipher[i]);
|
||||
|
||||
if(rc <= 0) break; else ja3_str_len += rc;
|
||||
}
|
||||
|
||||
if(JA3_STR_LEN > ja3_str_len) {
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
|
||||
if(rc > 0 && ja3_str_len + rc < JA3_STR_LEN) ja3_str_len += rc;
|
||||
}
|
||||
|
||||
/* ********** */
|
||||
|
||||
for(i=0; (i<ja3.server.num_tls_extension) && (JA3_STR_LEN > ja3_str_len); i++) {
|
||||
int rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u", (i > 0) ? "-" : "", ja3.server.tls_extension[i]);
|
||||
int rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u", (i > 0) ? "-" : "", ja3.server.tls_extension[i]);
|
||||
|
||||
if(rc <= 0) break; else ja3_str_len += rc;
|
||||
}
|
||||
|
||||
if(ndpi_struct->enable_ja3_plus) {
|
||||
for(i=0; (i<ja3.server.num_elliptic_curve_point_format) && (JA3_STR_LEN > ja3_str_len); i++) {
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
(i > 0) ? "-" : "", ja3.server.elliptic_curve_point_format[i]);
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
|
||||
}
|
||||
|
||||
if((ja3.server.alpn[0] != '\0') && (JA3_STR_LEN > ja3_str_len)) {
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",%s", ja3.server.alpn);
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",%s", ja3.server.alpn);
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
|
||||
}
|
||||
|
||||
@@ -1547,7 +1548,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
ndpi_MD5Final(md5_hash, &ctx);
|
||||
|
||||
for(i=0, j=0; i<16; i++) {
|
||||
int rc = snprintf(&flow->protos.tls_quic.ja3_server[j],
|
||||
int rc = ndpi_snprintf(&flow->protos.tls_quic.ja3_server[j],
|
||||
sizeof(flow->protos.tls_quic.ja3_server)-j, "%02x", md5_hash[i]);
|
||||
if(rc <= 0) break; else j += rc;
|
||||
}
|
||||
@@ -1898,7 +1899,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
#endif
|
||||
|
||||
for(i=0; i<tot_signature_algorithms_len && s_offset+i<total_len; i++) {
|
||||
int rc = snprintf(&ja3.client.signature_algorithms[i*2], sizeof(ja3.client.signature_algorithms)-i*2, "%02X", packet->payload[s_offset+i]);
|
||||
int rc = ndpi_snprintf(&ja3.client.signature_algorithms[i*2], sizeof(ja3.client.signature_algorithms)-i*2, "%02X", packet->payload[s_offset+i]);
|
||||
|
||||
if(rc < 0) break;
|
||||
}
|
||||
@@ -2048,7 +2049,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
if(flow->protos.tls_quic.alpn == NULL)
|
||||
flow->protos.tls_quic.alpn = ndpi_strdup(alpn_str);
|
||||
|
||||
snprintf(ja3.client.alpn, sizeof(ja3.client.alpn), "%s", alpn_str);
|
||||
ndpi_snprintf(ja3.client.alpn, sizeof(ja3.client.alpn), "%s", alpn_str);
|
||||
|
||||
/* Replace , with - as in JA3 */
|
||||
for(i=0; ja3.client.alpn[i] != '\0'; i++)
|
||||
@@ -2083,7 +2084,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
#endif
|
||||
|
||||
if((version_str_len+8) < sizeof(version_str)) {
|
||||
int rc = snprintf(&version_str[version_str_len],
|
||||
int rc = ndpi_snprintf(&version_str[version_str_len],
|
||||
sizeof(version_str) - version_str_len, "%s%s",
|
||||
(version_str_len > 0) ? "," : "",
|
||||
ndpi_ssl_version2str(buf_ver_tmp, sizeof(buf_ver_tmp), tls_version, &unknown_tls_version));
|
||||
@@ -2092,7 +2093,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
else
|
||||
version_str_len += rc;
|
||||
|
||||
rc = snprintf(&ja3.client.supported_versions[supported_versions_offset],
|
||||
rc = ndpi_snprintf(&ja3.client.supported_versions[supported_versions_offset],
|
||||
sizeof(ja3.client.supported_versions)-supported_versions_offset,
|
||||
"%s%04X", (j > 0) ? "-" : "", tls_version);
|
||||
|
||||
@@ -2232,47 +2233,47 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
int rc;
|
||||
|
||||
compute_ja3c:
|
||||
ja3_str_len = snprintf(ja3_str, JA3_STR_LEN, "%u,", ja3.client.tls_handshake_version);
|
||||
ja3_str_len = ndpi_snprintf(ja3_str, JA3_STR_LEN, "%u,", ja3.client.tls_handshake_version);
|
||||
|
||||
for(i=0; i<ja3.client.num_cipher; i++) {
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
(i > 0) ? "-" : "", ja3.client.cipher[i]);
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
|
||||
}
|
||||
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
|
||||
|
||||
/* ********** */
|
||||
|
||||
for(i=0; i<ja3.client.num_tls_extension; i++) {
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
(i > 0) ? "-" : "", ja3.client.tls_extension[i]);
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
|
||||
}
|
||||
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
|
||||
|
||||
/* ********** */
|
||||
|
||||
for(i=0; i<ja3.client.num_elliptic_curve; i++) {
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
(i > 0) ? "-" : "", ja3.client.elliptic_curve[i]);
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
|
||||
}
|
||||
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, ",");
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
|
||||
|
||||
for(i=0; i<ja3.client.num_elliptic_curve_point_format; i++) {
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len, "%s%u",
|
||||
(i > 0) ? "-" : "", ja3.client.elliptic_curve_point_format[i]);
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc; else break;
|
||||
}
|
||||
|
||||
if(ndpi_struct->enable_ja3_plus) {
|
||||
rc = snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len,
|
||||
rc = ndpi_snprintf(&ja3_str[ja3_str_len], JA3_STR_LEN-ja3_str_len,
|
||||
",%s,%s,%s", ja3.client.signature_algorithms, ja3.client.supported_versions, ja3.client.alpn);
|
||||
if((rc > 0) && (ja3_str_len + rc < JA3_STR_LEN)) ja3_str_len += rc;
|
||||
}
|
||||
@@ -2286,7 +2287,7 @@ int processClientServerHello(struct ndpi_detection_module_struct *ndpi_struct,
|
||||
ndpi_MD5Final(md5_hash, &ctx);
|
||||
|
||||
for(i=0, j=0; i<16; i++) {
|
||||
rc = snprintf(&flow->protos.tls_quic.ja3_client[j],
|
||||
rc = ndpi_snprintf(&flow->protos.tls_quic.ja3_client[j],
|
||||
sizeof(flow->protos.tls_quic.ja3_client)-j, "%02x",
|
||||
md5_hash[i]);
|
||||
if(rc > 0) j += rc; else break;
|
||||
|
||||
Vendored
+1
-1
@@ -63,7 +63,7 @@ do {
|
||||
#endif
|
||||
|
||||
/* a number of the hash function use uint32_t which isn't defined on Pre VS2010 */
|
||||
#if defined(_WIN32)
|
||||
#if defined(WIN32)
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1600
|
||||
#include <stdint.h>
|
||||
#elif defined(__WATCOMC__) || defined(__MINGW32__) || defined(__CYGWIN__)
|
||||
|
||||
+3
-3
@@ -629,11 +629,11 @@ static AC_ERROR_t dump_node_common(AC_AUTOMATA_t * thiz,
|
||||
char lbuf[512];
|
||||
int nl = 0,j;
|
||||
|
||||
nl = snprintf(lbuf,sizeof(lbuf),"'%.100s' N:%d{",rstr,n->matched_patterns->num);
|
||||
nl = ndpi_snprintf(lbuf,sizeof(lbuf),"'%.100s' N:%d{",rstr,n->matched_patterns->num);
|
||||
for (j=0; j<n->matched_patterns->num; j++) {
|
||||
AC_PATTERN_t *sid = &n->matched_patterns->patterns[j];
|
||||
if(j) nl += snprintf(&lbuf[nl],sizeof(lbuf)-nl-1,", ");
|
||||
nl += snprintf(&lbuf[nl],sizeof(lbuf)-nl-1,"%d %c%.100s%c",
|
||||
if(j) nl += ndpi_snprintf(&lbuf[nl],sizeof(lbuf)-nl-1,", ");
|
||||
nl += ndpi_snprintf(&lbuf[nl],sizeof(lbuf)-nl-1,"%d %c%.100s%c",
|
||||
sid->rep.number & 0x3fff,
|
||||
sid->rep.number & 0x8000 ? '^':' ',
|
||||
sid->astring,
|
||||
|
||||
Vendored
+2
-2
@@ -34,7 +34,7 @@
|
||||
#define GCM_VALIDATE( cond ) \
|
||||
MBEDTLS_INTERNAL_VALIDATE( cond )
|
||||
|
||||
#ifdef _WIN32
|
||||
#ifdef WIN32
|
||||
#define LBLOCKSIZE 4
|
||||
#else
|
||||
#define LBLOCKSIZE __SIZEOF_LONG__
|
||||
@@ -295,7 +295,7 @@ int mbedtls_gcm_starts( mbedtls_gcm_context *ctx,
|
||||
if( iv_len == 0)
|
||||
return( MBEDTLS_ERR_GCM_BAD_INPUT );
|
||||
#if __SIZE_WIDTH__ == 64
|
||||
if( iv_len >= (1UL << 32 ))
|
||||
if( iv_len >= (1ULL << 32 ))
|
||||
return( MBEDTLS_ERR_GCM_BAD_INPUT );
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#ifndef _WIN32
|
||||
#ifndef WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <string.h>
|
||||
|
||||
Vendored
+5
-5
@@ -300,7 +300,7 @@ static inline uint32_t croaring_detect_supported_architectures() {
|
||||
extern "C" { // portability definitions are in global scope, not a namespace
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__) && !defined(_WIN64) && !defined(ROARING_ACK_32BIT)
|
||||
#if defined(_MSC_VER) && !defined(__clang__) && !defined(WIN64) && !defined(ROARING_ACK_32BIT)
|
||||
#pragma message( \
|
||||
"You appear to be attempting a 32-bit build under Visual Studio. We recommend a 64-bit build instead.")
|
||||
#endif
|
||||
@@ -373,7 +373,7 @@ extern "C" { // portability definitions are in global scope, not a namespace
|
||||
/* result might be undefined when input_num is zero */
|
||||
static inline int __builtin_ctzll(unsigned long long input_num) {
|
||||
unsigned long index;
|
||||
#ifdef _WIN64 // highly recommended!!!
|
||||
#ifdef WIN64 // highly recommended!!!
|
||||
_BitScanForward64(&index, input_num);
|
||||
#else // if we must support 32-bit Windows
|
||||
if ((uint32_t)input_num != 0) {
|
||||
@@ -389,7 +389,7 @@ static inline int __builtin_ctzll(unsigned long long input_num) {
|
||||
/* result might be undefined when input_num is zero */
|
||||
static inline int __builtin_clzll(unsigned long long input_num) {
|
||||
unsigned long index;
|
||||
#ifdef _WIN64 // highly recommended!!!
|
||||
#ifdef WIN64 // highly recommended!!!
|
||||
_BitScanReverse64(&index, input_num);
|
||||
#else // if we must support 32-bit Windows
|
||||
if (input_num > 0xFFFFFFFF) {
|
||||
@@ -479,14 +479,14 @@ static inline int hammingbackup(uint64_t x) {
|
||||
}
|
||||
|
||||
static inline int hamming(uint64_t x) {
|
||||
#if defined(_WIN64) && defined(_MSC_VER) && !defined(__clang__)
|
||||
#if defined(WIN64) && defined(_MSC_VER) && !defined(__clang__)
|
||||
#ifdef _M_ARM64
|
||||
return hammingbackup(x);
|
||||
// (int) _CountOneBits64(x); is unavailable
|
||||
#else // _M_ARM64
|
||||
return (int) __popcnt64(x);
|
||||
#endif // _M_ARM64
|
||||
#elif defined(_WIN32) && defined(_MSC_VER) && !defined(__clang__)
|
||||
#elif defined(WIN32) && defined(_MSC_VER) && !defined(__clang__)
|
||||
#ifdef _M_ARM
|
||||
return hammingbackup(x);
|
||||
// _CountOneBits is unavailable
|
||||
|
||||
Reference in New Issue
Block a user