Skip to content

Commit

Permalink
Heap-buffer-overflow fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed Nov 4, 2024
1 parent b63f74a commit 4e18a56
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/lib/protocols/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -1034,23 +1034,26 @@ static void check_content_type_and_change_protocol(struct ndpi_detection_module_
"Digest", packet->authorization_line.len))) {
size_t content_len;
u_int len = b ? 7 : 6;
u_char *content = ndpi_base64_decode((const u_char*)&packet->authorization_line.ptr[len],
packet->authorization_line.len - len, &content_len);

if(content != NULL) {
char *double_dot = strchr((char*)content, ':');

if(double_dot) {
double_dot[0] = '\0';
flow->http.username = ndpi_strdup((char*)content);
flow->http.password = ndpi_strdup(&double_dot[1]);
}

ndpi_free(content);
}
if(packet->authorization_line.len > len) {
u_char *content = ndpi_base64_decode((const u_char*)&packet->authorization_line.ptr[len],
packet->authorization_line.len - len, &content_len);

if(content != NULL) {
char *double_dot = strchr((char*)content, ':');

if(double_dot) {
double_dot[0] = '\0';
flow->http.username = ndpi_strdup((char*)content);
flow->http.password = ndpi_strdup(&double_dot[1]);
}

ndpi_free(content);
}

ndpi_set_risk(flow, NDPI_CLEAR_TEXT_CREDENTIALS,
"Found credentials in HTTP Auth Line");
ndpi_set_risk(flow, NDPI_CLEAR_TEXT_CREDENTIALS,
"Found credentials in HTTP Auth Line");
}
}
}
}
Expand Down

0 comments on commit 4e18a56

Please sign in to comment.