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

added feature to extract filename from http attachment #2037

Merged
merged 9 commits into from
Jul 11, 2023
12 changes: 2 additions & 10 deletions src/lib/protocols/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,17 +291,9 @@ static ndpi_protocol_category_t ndpi_http_check_content(struct ndpi_detection_mo
if(packet->content_disposition_line.len > attachment_len) {
u_int8_t filename_len = packet->content_disposition_line.len - attachment_len;
int i;
if(packet->content_disposition_line.ptr[attachment_len] == '\"'){
//case: filename="file_name"
flow->http.filename = (char*)malloc((filename_len-3)*sizeof(char));
flow->http.filename = strncpy(flow->http.filename, (char*)packet->content_disposition_line.ptr+attachment_len+1, filename_len-2);
}
else{
//case: filename=file_name
flow->http.filename = (char*)malloc((filename_len-1)*sizeof(char));
flow->http.filename = strncpy(flow->http.filename, (char*)packet->content_disposition_line.ptr+attachment_len, filename_len);
}

flow->http.filename = ndpi_malloc(filename_len-1);
flow->http.filename = strncpy(flow->http.filename, (char*)packet->content_disposition_line.ptr+attachment_len, filename_len);
IvanNardi marked this conversation as resolved.
Show resolved Hide resolved

if(filename_len > ATTACHMENT_LEN) {
attachment_len += filename_len-ATTACHMENT_LEN-1;
Expand Down