New security checks

Added security checks to the data reader, so malicious/invalid packets
have no effect.