check that buf is a string