Check that the string is long enough before accessing it. With sufficent
optimization the code would unconditionally load two byte from the
string even if it was an empty string.
For old-style hashes, retain support for 1-byte salts. For new-style
hashes, require 9 non-NUL bytes. In both cases, don't check for
termination beyond that point as a programmer might have passed the
whole hash or an unterminated byte array.
Found with: CHERI
Sponsored by: Innovate UK