Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ASN1/BER: fix signed integer overflow #1660

Merged
merged 1 commit into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/include/ndpi_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ extern "C" {
char *ndpi_hostname_sni_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);

int ndpi_asn1_ber_decode_length(const unsigned char *payload, int payload_len, u_int16_t *value_len);
int64_t ndpi_asn1_ber_decode_length(const unsigned char *payload, int payload_len, u_int16_t *value_len);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ndpi_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -2707,7 +2707,7 @@ u_int8_t ndpi_check_flow_risk_exceptions(struct ndpi_detection_module_struct *nd

/* ******************************************* */

int ndpi_asn1_ber_decode_length(const unsigned char *payload, int payload_len, u_int16_t *value_len)
int64_t ndpi_asn1_ber_decode_length(const unsigned char *payload, int payload_len, u_int16_t *value_len)
{
unsigned int value, i;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/protocols/kerberos.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static int krb_decode_asn1_length(struct ndpi_detection_module_struct *ndpi_stru
size_t * const kasn1_offset)
{
struct ndpi_packet_struct * const packet = &ndpi_struct->packet;
int length;
int64_t length;
u_int16_t value_len;

length = ndpi_asn1_ber_decode_length(&packet->payload[*kasn1_offset],
Expand Down
2 changes: 1 addition & 1 deletion src/lib/protocols/ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void ndpi_int_ldap_add_connection(struct ndpi_detection_module_struct *nd
void ndpi_search_ldap(struct ndpi_detection_module_struct *ndpi_struct, struct ndpi_flow_struct *flow)
{
struct ndpi_packet_struct *packet = &ndpi_struct->packet;
int length;
int64_t length;
u_int16_t length_len = 0, msg_id_len;
u_int8_t op;

Expand Down
2 changes: 1 addition & 1 deletion src/lib/protocols/snmp_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void ndpi_search_snmp(struct ndpi_detection_module_struct *ndpi_struct,

if(packet->payload_packet_len > 16 && packet->payload[0] == 0x30) {
u_int16_t len_length = 0, offset;
int len;
int64_t len;

len = ndpi_asn1_ber_decode_length(&packet->payload[1], packet->payload_packet_len - 1, &len_length);

Expand Down