/* Unpacks utf8 string from the buffer from the offset requested.  */
static int unpack_utf8_str(struct buf_ctx *buf, struct mqtt_utf8 *str)
/* Unpacks utf8 string from the buffer from the offset requested.  */
static int unpack_utf8_str(struct buf_ctx *buf, struct mqtt_utf8 *str)
{
	uint16_t utf8_strlen;
	int err_code;
	NET_DBG(">> cur:%p, end:%p", (void *)buf->cur, (void *)buf->end);
	err_code = unpack_uint16(buf, &utf8_strlen);
	if (err_code != 0) {
		return err_code;
	}
	if ((buf->end - buf->cur) < utf8_strlen) {
		return -EINVAL;
	}
	str->size = utf8_strlen;
	if (utf8_strlen) {
		str->utf8 = buf->cur;
		buf->cur += utf8_strlen;
	} else {
		str->utf8 = NULL;
	}
	NET_DBG("<< str_size:%08x", (uint32_t)GET_UT8STR_BUFFER_SIZE(str));
	return 0;
}