Make this check `msg_len < 8` and move it before the call to dissect_of_message. That should makes the buf:len() check in dissect_of_message redundant.