Minor cleanup
This commit is contained in:
+13
-1
@@ -96,9 +96,12 @@ static void ndpi_int_ssh_add_connection(struct ndpi_detection_module_struct
|
|||||||
static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
|
static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
|
||||||
char *buf, u_int8_t client_hash) {
|
char *buf, u_int8_t client_hash) {
|
||||||
u_int32_t offset = 22, buf_out_len = 0;
|
u_int32_t offset = 22, buf_out_len = 0;
|
||||||
|
int len;
|
||||||
|
|
||||||
if(offset+sizeof(u_int32_t) >= packet->payload_packet_len)
|
if(offset+sizeof(u_int32_t) >= packet->payload_packet_len)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
u_int32_t len = ntohl(*(u_int32_t*)&packet->payload[offset]);
|
|
||||||
|
len = ntohl(*(u_int32_t*)&packet->payload[offset]);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
/* -1 for ';' */
|
/* -1 for ';' */
|
||||||
@@ -112,14 +115,17 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
|
|||||||
|
|
||||||
if(offset+sizeof(u_int32_t) >= packet->payload_packet_len)
|
if(offset+sizeof(u_int32_t) >= packet->payload_packet_len)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
|
|
||||||
/* ssh.server_host_key_algorithms [None] */
|
/* ssh.server_host_key_algorithms [None] */
|
||||||
len = ntohl(*(u_int32_t*)&packet->payload[offset]);
|
len = ntohl(*(u_int32_t*)&packet->payload[offset]);
|
||||||
|
|
||||||
if(len > UINT32_MAX - 8 - offset)
|
if(len > UINT32_MAX - 8 - offset)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
offset += 4 + len;
|
offset += 4 + len;
|
||||||
|
|
||||||
if(offset+sizeof(u_int32_t) >= packet->payload_packet_len)
|
if(offset+sizeof(u_int32_t) >= packet->payload_packet_len)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
|
|
||||||
/* ssh.encryption_algorithms_client_to_server [C] */
|
/* ssh.encryption_algorithms_client_to_server [C] */
|
||||||
len = ntohl(*(u_int32_t*)&packet->payload[offset]);
|
len = ntohl(*(u_int32_t*)&packet->payload[offset]);
|
||||||
|
|
||||||
@@ -132,12 +138,14 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
|
|||||||
buf_out_len += len;
|
buf_out_len += len;
|
||||||
buf[buf_out_len++] = ';';
|
buf[buf_out_len++] = ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(len > UINT32_MAX - 4 - offset)
|
if(len > UINT32_MAX - 4 - offset)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
offset += len;
|
offset += len;
|
||||||
|
|
||||||
if(offset+sizeof(u_int32_t) >= packet->payload_packet_len)
|
if(offset+sizeof(u_int32_t) >= packet->payload_packet_len)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
|
|
||||||
/* ssh.encryption_algorithms_server_to_client [S] */
|
/* ssh.encryption_algorithms_server_to_client [S] */
|
||||||
len = ntohl(*(u_int32_t*)&packet->payload[offset]);
|
len = ntohl(*(u_int32_t*)&packet->payload[offset]);
|
||||||
|
|
||||||
@@ -150,6 +158,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
|
|||||||
buf_out_len += len;
|
buf_out_len += len;
|
||||||
buf[buf_out_len++] = ';';
|
buf[buf_out_len++] = ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(len > UINT32_MAX - 4 - offset)
|
if(len > UINT32_MAX - 4 - offset)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
offset += len;
|
offset += len;
|
||||||
@@ -186,6 +195,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
|
|||||||
buf_out_len += len;
|
buf_out_len += len;
|
||||||
buf[buf_out_len++] = ';';
|
buf[buf_out_len++] = ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(len > UINT32_MAX - 4 - offset)
|
if(len > UINT32_MAX - 4 - offset)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
offset += len;
|
offset += len;
|
||||||
@@ -203,6 +213,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
|
|||||||
strncpy(&buf[buf_out_len], (const char *)&packet->payload[offset], len);
|
strncpy(&buf[buf_out_len], (const char *)&packet->payload[offset], len);
|
||||||
buf_out_len += len;
|
buf_out_len += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(len > UINT32_MAX - 4 - offset)
|
if(len > UINT32_MAX - 4 - offset)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
offset += len;
|
offset += len;
|
||||||
@@ -220,6 +231,7 @@ static u_int16_t concat_hash_string(struct ndpi_packet_struct *packet,
|
|||||||
strncpy(&buf[buf_out_len], (const char *)&packet->payload[offset], len);
|
strncpy(&buf[buf_out_len], (const char *)&packet->payload[offset], len);
|
||||||
buf_out_len += len;
|
buf_out_len += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(len > UINT32_MAX - offset)
|
if(len > UINT32_MAX - offset)
|
||||||
goto invalid_payload;
|
goto invalid_payload;
|
||||||
offset += len;
|
offset += len;
|
||||||
|
|||||||
Reference in New Issue
Block a user