Cosmetic changes

This commit is contained in:
Luca Deri
2022-08-03 11:31:32 +02:00
parent 63fe4b4306
commit c3c73e7bff
+16 -16
View File
@@ -374,7 +374,8 @@ ndpi_port_range *ndpi_build_default_ports(ndpi_port_range *ports, u_int16_t port
/* ********************************************************************************** */ /* ********************************************************************************** */
void ndpi_set_proto_breed(struct ndpi_detection_module_struct *ndpi_str, u_int16_t protoId, ndpi_protocol_breed_t breed) { void ndpi_set_proto_breed(struct ndpi_detection_module_struct *ndpi_str,
u_int16_t protoId, ndpi_protocol_breed_t breed) {
if(!ndpi_is_valid_protoId(protoId)) if(!ndpi_is_valid_protoId(protoId))
return; return;
else else
@@ -439,10 +440,10 @@ void ndpi_set_proto_subprotocols(struct ndpi_detection_module_struct *ndpi_str,
{ {
va_list ap; va_list ap;
int current_arg = protoId; int current_arg = protoId;
size_t i = 0;
va_start(ap, protoId); va_start(ap, protoId);
while (current_arg != NDPI_PROTOCOL_NO_MORE_SUBPROTOCOLS) while (current_arg != NDPI_PROTOCOL_NO_MORE_SUBPROTOCOLS) {
{
ndpi_str->proto_defaults[protoId].subprotocol_count++; ndpi_str->proto_defaults[protoId].subprotocol_count++;
current_arg = va_arg(ap, int); current_arg = va_arg(ap, int);
} }
@@ -453,22 +454,23 @@ void ndpi_set_proto_subprotocols(struct ndpi_detection_module_struct *ndpi_str,
/* The last protocol is not a subprotocol. */ /* The last protocol is not a subprotocol. */
ndpi_str->proto_defaults[protoId].subprotocol_count--; ndpi_str->proto_defaults[protoId].subprotocol_count--;
/* No subprotocol was set before NDPI_NO_MORE_SUBPROTOCOLS. */ /* No subprotocol was set before NDPI_NO_MORE_SUBPROTOCOLS. */
if (ndpi_str->proto_defaults[protoId].subprotocol_count == 0) if(ndpi_str->proto_defaults[protoId].subprotocol_count == 0) {
{
return; return;
} }
ndpi_str->proto_defaults[protoId].subprotocols = ndpi_str->proto_defaults[protoId].subprotocols =
ndpi_malloc(sizeof(protoId) * ndpi_str->proto_defaults[protoId].subprotocol_count); ndpi_malloc(sizeof(protoId) * ndpi_str->proto_defaults[protoId].subprotocol_count);
size_t i = 0;
va_start(ap, protoId); va_start(ap, protoId);
current_arg = va_arg(ap, int); current_arg = va_arg(ap, int);
while (current_arg != NDPI_PROTOCOL_NO_MORE_SUBPROTOCOLS)
{ while (current_arg != NDPI_PROTOCOL_NO_MORE_SUBPROTOCOLS) {
if(ndpi_str->proto_defaults[protoId].subprotocols != NULL) {
ndpi_str->proto_defaults[protoId].subprotocols[i++] = current_arg; ndpi_str->proto_defaults[protoId].subprotocols[i++] = current_arg;
current_arg = va_arg(ap, int); current_arg = va_arg(ap, int);
} }
}
va_end(ap); va_end(ap);
} }
@@ -8819,8 +8821,8 @@ ndpi_risk_info* ndpi_risk2severity(ndpi_risk_enum risk) {
/* ******************************************************************** */ /* ******************************************************************** */
char *ndpi_hostname_sni_set(struct ndpi_flow_struct *flow, const u_int8_t *value, size_t value_len) char *ndpi_hostname_sni_set(struct ndpi_flow_struct *flow,
{ const u_int8_t *value, size_t value_len) {
char *dst; char *dst;
size_t len, i; size_t len, i;
@@ -8836,16 +8838,14 @@ char *ndpi_hostname_sni_set(struct ndpi_flow_struct *flow, const u_int8_t *value
/* ******************************************************************** */ /* ******************************************************************** */
char *ndpi_user_agent_set(struct ndpi_flow_struct *flow, const u_int8_t *value, size_t value_len) char *ndpi_user_agent_set(struct ndpi_flow_struct *flow,
{ const u_int8_t *value, size_t value_len) {
if (flow->http.user_agent != NULL) if(flow->http.user_agent != NULL) {
{
return NULL; return NULL;
} }
flow->http.user_agent = ndpi_malloc(value_len + 1); flow->http.user_agent = ndpi_malloc(value_len + 1);
if (flow->http.user_agent != NULL) if(flow->http.user_agent != NULL) {
{
memcpy(flow->http.user_agent, value, value_len); memcpy(flow->http.user_agent, value, value_len);
flow->http.user_agent[value_len] = '\0'; flow->http.user_agent[value_len] = '\0';
} }