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

Invalid code in ndpi_util.c #364

Closed
Ravi-t opened this issue Apr 19, 2017 · 4 comments
Closed

Invalid code in ndpi_util.c #364

Ravi-t opened this issue Apr 19, 2017 · 4 comments
Assignees

Comments

@Ravi-t
Copy link

Ravi-t commented Apr 19, 2017

In function named "packet_processing" line number 546, it will result in a crash

if(flow != NULL) {
workflow->stats.ip_packet_count++;
workflow->stats.total_wire_bytes += rawsize + 24 /* CRC etc */,
workflow->stats.total_ip_bytes += rawsize;
ndpi_flow = flow->ndpi_flow;
flow->packets++, flow->bytes += rawsize;
flow->last_seen = time;
} else {
return(flow->detected_protocol); // This line will result in a crash as flow is NULL
}

@Ravi-t
Copy link
Author

Ravi-t commented Apr 19, 2017

The function get_ndpi_flow_info always returns NULL value for fragmented packets because of following code at line 222 in ndpi_util.c

if((iph->ihl * 4) > ipsize || ipsize < ntohs(iph->tot_len)
|| (iph->frag_off & htons(0x1FFF)) != 0)
return NULL;

@kYroL01 kYroL01 self-assigned this Apr 19, 2017
@kYroL01
Copy link
Contributor

kYroL01 commented Apr 19, 2017

@Ravi-t I think you're right but i can fix later.
Please be patient, but thank you so much for this reporting.

@Ravi-t
Copy link
Author

Ravi-t commented Apr 19, 2017

I think either ndpiReader should support fragments else in function "packet_processing" we should declare a new variable called nproto as
struct ndpi_proto nproto = { NDPI_PROTOCOL_UNKNOWN, NDPI_PROTOCOL_UNKNOWN };
and on line 546 return nproto instead of flow->detected_protocol to avoid the crash
so that it looks as

if(flow != NULL) {
workflow->stats.ip_packet_count++;
workflow->stats.total_wire_bytes += rawsize + 24 /* CRC etc */,
workflow->stats.total_ip_bytes += rawsize;
ndpi_flow = flow->ndpi_flow;
flow->packets++, flow->bytes += rawsize;
flow->last_seen = time;
} else {
//return(flow->detected_protocol);
return nproto;

}

@kYroL01
Copy link
Contributor

kYroL01 commented Apr 19, 2017

You can also send a pull request if you prefer.
I'm watching later. Thanks

kYroL01 pushed a commit that referenced this issue Apr 20, 2017
@kYroL01 kYroL01 closed this as completed Apr 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants