Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Abstract reader/writer issue with non-contigous input data

未关闭
#250 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
c, cpp
领域
embedded-iot

调研方向

首先跟踪 CborParserOperations 及其 transfer_string 函数在 cbor_value_copy_text_string 中的调用路径,然后比较 cbor_value_advance 和 cbor_value_get_type 对两个 CborValue 对象的行为。复现所提供的非连续迭代器示例,最好将其缩减为最小案例;当原始值和输出的下一个值按描述推进且不出现 CborErrorIllegalType 时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

So I think this may be related to and/or covered by #208 , but I wanted to open an issue to report the specifics of what i am seeing.

I think the root of the issue is that in the structure CborParserOperations the function pointer transfer_string should advance the cursor but when calling CborError cbor_value_copy_text_string(const CborValue *value, char *buffer, size_t *buflen, CborValue *next) the cursor should be advanced for the output parameter next but not advanced in the in-out parameter value. I think the user data token* is shared between copies of CborValue.

I am working in an embedded system and transitioning some existing code to use a struct netbuff like structure instead of just copying around worst-case sized buffers. To do this i need to move all my code to work on iterators instead of just taking a std::span<uint8_t> (we are on C++20). The iterators to this new structure are bidirectional_iterator, so no random access.

A simple (exposition only) example of the code that fails:

detail::ParserState<InItr, S> cbor_parse;
CborValue it;
cbor_parse.init(data.begin(), data.end(), it);
CborValue it2;
char func_name_buff[10]{};
size_t name_len = 10;
if (!cbor_value_is_text_string(&it)) {
    return BadValue;
}
if (auto err = cbor_value_copy_text_string(&it, func_name_buff, &name_len, &it2) != CborNoError) {
    return err;
}
auto errr = cbor_value_advance(&it);    // ERROR: CborErrorIllegalType
auto type = cbor_value_get_type(&it)    // CborTextStringType, should be NullType after the advance
auto type2 = cbor_value_get_type(&it2)  // CborNullType

I will work on getting a minimal reproducible example into compiler explorer, especially if this is a new case.

主要语言
C
星标
640
派生
222
平均合并
41 分钟
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

intel/tinycbor 的其他 Issue

查看 intel/tinycbor 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。