Buffer full when inserting latter value of pair to the map
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- c
调研方向
从 issue 中所示的 cbor_encoder_create_map 和 cbor_encode_byte_string 调用开始,然后检查缓冲区已满错误会如何影响 encoder 状态。确定失败的值是否会使 map 留下一个不匹配的键,并记录或测试针对静态分配缓冲区所支持的恢复过程。
由索引模型根据 Issue 内容生成。
描述
Hi!
I have a question which I have not found answer for. Since map contains pairs of items and I understood basically as dictionary (albeit basically same key could occur there multiple times but in my use case not), first value being a key and second one being a value.
So something like:
uint8_t payload[BUFFER_SIZE];
CborEncoder encoder, mapEncoder;
cbor_encoder_init(&encoder, payload, BUFFER_SIZE, 0);
cbor_encoder_create_map(&encoder, &mapEncoder, CborIndefiniteLength); // Don't know in advance how many
...
// Key value pairs are inserted
// until buffer is almost full
...
// Here, inserting key that still fits. Using uint key values for length optimization
// This one succeeds
cbor_encode_uint(&mapEncoder, 0xDEAD);
// Not matter what is the value but something that does not fit. For example string
CborError err = cbor_encode_byte_string(&mapEncoder, "whatever", 8);
What would be the correct procedure to take when writing a key fits to buffer but when writing the value, the buffer is exceeded? We have statically allocated buffer of specific size so it is not possible to reallocate more room.
Currently I'm now evaluating the size of the key+value beforehand and then evaluating whether whole key+value combination is inserted at all. Albeit it works, it feels bit ugly. Instead, if writing of the value fails, the key could be reverted as well (because otherwise when map is closed, last item contains only key and not value). I cannot find any means to do that though.
Any suggestions?
PS Otherwise, this works like a charm and fits to my use case perfectly.
- 主要语言
- C
- 星标
- 641
- 派生
- 222
- 平均合并
- 21 小时 33 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
intel/tinycbor 的其他 Issue
-
CborValidateTagUse rejects valid tag 1 (epoch) with a floating-point value, and restricts tags 21-23 too much可能已有人在做 @thiagomacieira 于 17 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 38/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
FujiNetWIFI/fujinet-firmware#2079 ·
维护者通常 1 天内回复
-
bug Official Image release/25.12 Supported Device target/kirkwood
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
area/archive bug
难度 2/5 1-3 小时 新手友好度 76/100
DarkFlippers/qUnleashed#374 ·
维护者通常 1 天内回复
-
bug
难度 1/5 1 小时以内 新手友好度 84/100
VirusTotal/yara#2255 ·
-
难度 2/5 1-3 小时 新手友好度 66/100