dns: Add some safety checks to get_name_real

A server (or a malicious entity) could send a pointer off the end of
the request, or pointers back onto the same name, both of which would
have previously crashed get_name_real.