Pass msglen to avoid embedded null problem with strings