diff options
-rw-r--r-- | dependencies/nDPIsrvd.h | 12 | ||||
-rw-r--r-- | dependencies/uthash/doc/styles.css | 1 | ||||
-rw-r--r-- | examples/c-captured/c-captured.c | 5 | ||||
-rw-r--r-- | examples/c-collectd/c-collectd.c | 5 | ||||
-rw-r--r-- | examples/c-json-stdout/c-json-stdout.c | 2 | ||||
-rw-r--r-- | nDPId-test.c | 2 | ||||
-rw-r--r-- | nDPId.c | 2 |
7 files changed, 20 insertions, 9 deletions
diff --git a/dependencies/nDPIsrvd.h b/dependencies/nDPIsrvd.h index 5b1144d17..3dcb5d24f 100644 --- a/dependencies/nDPIsrvd.h +++ b/dependencies/nDPIsrvd.h @@ -672,7 +672,7 @@ static inline int nDPIsrvd_setup_address(struct nDPIsrvd_address * const address } if (destination[0] == '[') { - if (*(last_colon - 1) != ']') + if (last_colon > destination && *(last_colon - 1) != ']') { return 1; } @@ -1645,11 +1645,21 @@ static inline void nDPIsrvd_flow_info(struct nDPIsrvd_socket const * const sock, static inline int nDPIsrvd_json_buffer_length(struct nDPIsrvd_socket const * const sock) { + if (sock == NULL) + { + return 0; + } + return (int)sock->buffer.json_string_length - NETWORK_BUFFER_LENGTH_DIGITS; } static inline char const *nDPIsrvd_json_buffer_string(struct nDPIsrvd_socket const * const sock) { + if (sock == NULL) + { + return NULL; + } + return sock->buffer.json_string; } diff --git a/dependencies/uthash/doc/styles.css b/dependencies/uthash/doc/styles.css index 061172232..fde9e2a8d 100644 --- a/dependencies/uthash/doc/styles.css +++ b/dependencies/uthash/doc/styles.css @@ -29,7 +29,6 @@ h1,p { margin: 0; } /* non-0 margin on firefox */ background-repeat: repeat-y; /* background-color: #ffddaa; */ padding-top: 20px; - padding-top: 20px; margin-bottom: 10px; } diff --git a/examples/c-captured/c-captured.c b/examples/c-captured/c-captured.c index 8eac71ab3..e810f3e70 100644 --- a/examples/c-captured/c-captured.c +++ b/examples/c-captured/c-captured.c @@ -1354,7 +1354,10 @@ int main(int argc, char ** argv) } return 1; } - chmod(datadir, S_IRWXU); + if (datadir != NULL) + { + chmod(datadir, S_IRWXU); + } if (nDPIsrvd_set_read_timeout(sock, 180, 0) != 0) { diff --git a/examples/c-collectd/c-collectd.c b/examples/c-collectd/c-collectd.c index 30e8da553..3f8e2aef0 100644 --- a/examples/c-collectd/c-collectd.c +++ b/examples/c-collectd/c-collectd.c @@ -726,7 +726,7 @@ static enum nDPIsrvd_callback_return collectd_json_callback(struct nDPIsrvd_sock struct nDPIsrvd_json_token const * current = NULL; int next_child_index = -1; - if (flow_risk != NULL) + if (flow_risk != NULL && flow_user_data != NULL) { if (flow_user_data->detected_risks == 0) { @@ -744,13 +744,12 @@ static enum nDPIsrvd_callback_return collectd_json_callback(struct nDPIsrvd_sock if (numeric_risk_value < NDPI_MAX_RISK && numeric_risk_value > 0) { collectd_statistics.flow_risk_count[numeric_risk_value - 1]++; + flow_user_data->detected_risks |= (1ull << (numeric_risk_value - 1)); } else { collectd_statistics.flow_risk_unknown_count++; } - - flow_user_data->detected_risks |= (1ull << (numeric_risk_value - 1)); } } } diff --git a/examples/c-json-stdout/c-json-stdout.c b/examples/c-json-stdout/c-json-stdout.c index 508e45588..ae082a366 100644 --- a/examples/c-json-stdout/c-json-stdout.c +++ b/examples/c-json-stdout/c-json-stdout.c @@ -104,7 +104,7 @@ int main(void) json_bytes - json_start, tokens, sizeof(tokens) / sizeof(tokens[0])); - if (r < 0 || tokens[0].type != JSMN_OBJECT) + if (r < 1 || tokens[0].type != JSMN_OBJECT) { fprintf(stderr, "JSON parsing failed with return value %d at position %u\n", r, parser.pos); fprintf(stderr, "JSON string: '%.*s'\n", (int)(json_bytes - json_start), (char *)(buf + json_start)); diff --git a/nDPId-test.c b/nDPId-test.c index 11cd81bc8..19f93be4a 100644 --- a/nDPId-test.c +++ b/nDPId-test.c @@ -1454,7 +1454,7 @@ static int base64_selftest() "0hr4QS1hduMHTwKBXqjb4CGVJbxoc+S/7hjTHGDqWhHCpq9+4SQxcR6MVp65BVNMdGJRLMiHAkUWvivJW4DOanO//" "36RFuMQEAQEAUMabZOvBbAa1KSTcWbL5ZGc/YPxLofmSTDMxf+KmqSukiR3yVasPbv5J6Hx2zCATM9pR9VRArg=="; - size_t encoded_len = strlen(encoded_buf); + size_t encoded_len = strnlen(encoded_buf, sizeof(encoded_buf)); unsigned char decoded_buf[nDPId_PACKETS_PLEN_MAX]; size_t decoded_len = sizeof(decoded_buf); if (nDPIsrvd_base64decode(encoded_buf, encoded_len, decoded_buf, &decoded_len) != 0) @@ -4252,7 +4252,7 @@ static void ndpi_process_packet(uint8_t * const args, free_detection_data(flow_to_process); flow_to_process->flow_extended.flow_basic.state = FS_FINISHED; - struct nDPId_flow * const flow = (struct nDPId_flow *)flow_to_process; + struct nDPId_flow * const flow = flow_to_process; flow->flow_extended.detected_l7_protocol = detected_l7_protocol; flow->finished.risk = risk; flow->finished.confidence = confidence; |