bugfix: buf must be unsigned char