Check for empty strings and zero bytes in is_valid_ip.

Closes #893.