We mostly use classical C strings, but the memory management around them
can get confusing and error prone. Let's use std::string for the cases
where we need to return a newly allocated string.
If there isn't enough data, then the client reading the hash will fall
down and try to read the subtype instead, which isn't correct.
Invert the logic so we get a more consistent way through where we only
break out when there is insufficient data.
Do the same for the server code, for consistency.