As long as you know the length of the entire buffer, you just ensure that:
current_addr + message_len - start_addr < buffer_len
Or am I missing something? current_addr + message_len - start_addr < buffer_len
Or am I missing something?Similar to HeartBleed, where there wasn't validation on the heartbeat message, and the server would echo back buffer_len instead of just what was sent.
I can think of a very contrived situation where this can be a problem, but in most cases this will be perfectly safe.