createmsgiddir(): fix potential stack buffer write overflow
If unexpected directories with high numbers as a prefix appear, then the
havedir array can be overflowed. During regular operation this
shouldn't happen, therefore this is only a hardening.