Fix IPv6 address and avoid exception when part of name isn't in buffer