Check length first in BUF_strnlen().