Skip to content

lwkoon/AMBEserver2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Above is one way to modify the code in the UDP processing function so that a corrupted packet (for example, one with an invalid payload length) is simply dropped rather than forwarded to the AMBE3000. In the updated version of the processSocket() function, we check that the payload length (after converting from network byte order) does not exceed the size of the payload buffer. If it does, we print an error message and ignore the packet.

Explanation:

Start Byte Check: The code first confirms that the packet begins with the expected start byte (0x61). If not, it logs the error and skips processing.

Payload Length Validation: After converting the payload length from network byte order, we compare it against the maximum size of the payload union. This prevents a corrupted packet (for example, one where the payload length is much larger than expected) from causing a buffer overflow or an erroneous behavior.

Packet Size Verification: The function then computes the expected size of the packet and ensures the received packet exactly matches this size.

Safe Forwarding: Only after these checks is the packet forwarded to the AMBE3000 over the serial interface.

This approach should help prevent crashes or lock-ups of the AMBE3000 due to bad internet packets.

to compile just use any linux distribution

debian/ubuntu

sudo apt install build-essential

gcc -o AMBEserver AMBEserver.c

About

modified AMBEserver2

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors