Implement BUF_strnlen() and use it instead of strlen().
Remove redundant test.