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

implementation not resistant to duplicate packets #8

Closed
bmegli opened this issue Apr 5, 2020 · 2 comments
Closed

implementation not resistant to duplicate packets #8

bmegli opened this issue Apr 5, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@bmegli
Copy link
Owner

bmegli commented Apr 5, 2020

Looking at the implementation I see that the library doesn't handle duplicate UDP packets correctly.

There is no guarantee that UDP packets will not arrive multiple times.

Looking at the code here:

   memcpy(m->collected.data + udp.packet*PACKET_MAX_PAYLOAD, udp.data, udp.size);

   ++m->collected.collected_packets;
   m->collected.actual_size += udp.size;

   if(m->collected.collected_packets == udp.packets)

we see that duplicate packets are not taken into account and may brake packet collection or in the worst case, if they slip through sanity checks, we could interpret incomplete frame as complete.

The correct way to do it is to:

  • for each frame
  • keep track of its collected packets (by nr)
  • only if we have all parts (tracked by packet number)
  • return full frame

Possibly related to UNHVD#10,

@bmegli bmegli added the bug Something isn't working label Apr 5, 2020
@bmegli
Copy link
Owner Author

bmegli commented Apr 14, 2020

This is fixable in around 10 lines of code.

Nonetheless this has to wait, at least until merging multi-frame support to master.

@bmegli
Copy link
Owner Author

bmegli commented May 5, 2020

This also fulfills requirements for HVS#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant