dissect_kafka_regular_bytes(proto_tree *tree, int hf_item, tvbuff_t *tvb, packet_info *pinfo, int offset,
                    int *p_offset, int *p_length)
{
    gint16 length;
    proto_item *pi;

    length = (gint16) tvb_get_ntohs(tvb, offset);
    if (length < -1) {
        pi = proto_tree_add_item(tree, hf_item, tvb, offset, 0, ENC_NA);
        expert_add_info(pinfo, pi, &ei_kafka_bad_string_length);
        if (p_offset) {
            *p_offset = 2;
        }
        if (p_length) {
            *p_length = 0;
        }
        return offset + 2;
    }

    if (length == -1) {
        proto_tree_add_bytes_with_length(tree, hf_item, tvb, offset, 2, NULL, 0);
    } else {
        proto_tree_add_bytes_with_length(tree, hf_item, tvb, offset, length + 2,
        tvb_get_ptr(tvb, offset + 2, length),
                length);
    }

    if (p_offset != NULL) *p_offset = offset + 2;
    if (p_length != NULL) *p_length = length;

    offset += 2;
    if (length != -1) offset += length;

    return offset;
}
dissect_kafka_regular_bytes(proto_tree *tree, int hf_item, tvbuff_t *tvb, packet_info *pinfo, int offset,
                    int *p_offset, int *p_length)
{
    gint16 length;
    proto_item *pi;

    length = (gint16) tvb_get_ntohs(tvb, offset);
    if (length < -1) {
        pi = proto_tree_add_item(tree, hf_item, tvb, offset, 0, ENC_NA);
        expert_add_info(pinfo, pi, &ei_kafka_bad_string_length);
        if (p_offset) {
            *p_offset = 2;
        }
        if (p_length) {
            *p_length = 0;
        }
        return offset + 2;
    }

    if (length == -1) {
        proto_tree_add_bytes_with_length(tree, hf_item, tvb, offset, 2, NULL, 0);
    } else {
        proto_tree_add_bytes_with_length(tree, hf_item, tvb, offset, length + 2,
        tvb_get_ptr(tvb, offset + 2, length),
                length);
    }

    if (p_offset != NULL) *p_offset = offset + 2;
    if (p_length != NULL) *p_length = length;

    offset += 2;
    if (length != -1) offset += length;

    return offset;
}