CborValidateTagUse rejects valid tag 1 (epoch) with a floating-point value, and restricts tags 21-23 too much
评估
调研方向
检查 src/cborvalidation.c 和 knownTagData 表,然后跟踪 cbor_value_validate 如何应用 CborValidateTagUse。使用整数和浮点值测试 tag 1,并使用不同的内容类型测试 tags 21–23;完成的标准是这些有效的 RFC 8949 用例返回 CborNoError,同时现有的限制仍得到覆盖。
由索引模型根据 Issue 内容生成。
描述
CborValidateTagUse refuses valid CBOR for two groups of tags, because of the knownTagData table in src/cborvalidation.c (checked at main, 213155c8, and in the v7.0 release).
Tag 1 (epoch-based date/time) with a float
{ 1, (uint32_t)(CborIntegerType+1) },
allows only an integer. RFC 8949 §3.4.2 says:
The tag content MUST be an unsigned or negative integer (major types 0 and 1) or a floating-point number (major type 7 with additional information 25, 26, or 27).
So RFC 8949's own Appendix A example 1(1363896240.5), c1fb41d452d9ec200000, fails validation with CborErrorInappropriateTagForType:
static const uint8_t item[] = {0xc1, 0xfb, 0x41, 0xd4, 0x52, 0xd9, 0xec, 0x20, 0x00, 0x00};
CborParser parser;
CborValue it;
cbor_parser_init(item, sizeof item, 0, &parser, &it);
CborError err = cbor_value_validate(&it, CborValidateTagUse);
/* err == CborErrorInappropriateTagForType; expected CborNoError */
The same happens for a half or single-precision float under tag 1.
Tags 21, 22 and 23
These entries allow only a byte string, array or map. RFC 8949 §3.4.5.2 says:
The data item tagged can be a byte string or any other data item.
So, for example, 21("text") (d5 64 74 65 78 74) or 23(1) (d7 01) is refused, although it is valid.
Suggested fix
- Tag 1: allow
CborHalfFloatType,CborFloatTypeandCborDoubleTypealongside the integer. - Tags 21–23: give them no type restriction, as tag 55799 has.
(Found while writing conformance tests for an R binding of TinyCBOR, zucbor, which now checks tag content itself as a workaround.)
- 主要语言
- C
- 星标
- 641
- 派生
- 222
- 平均合并
- 21 小时 33 分钟
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
intel/tinycbor 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 45/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 38/100
-
Fixing CI/CD未关闭
难度 2/5 1-3 小时 新手友好度 25/100
相似的 Issue
-
category:port-update
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 8 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 90/100
维护者通常 1 天内回复
-
native-cpu: -Wreturn-type in skainet_row_threads.c:150 (worker fn has no return)可能已有人在做 @Doomguy-BFG9000 今天认领。 未关闭good first issue size:xs skill:native
难度 1/5 1 小时以内 新手友好度 78/100
SKaiNET-developers/SKaiNET#1358 · 1 条评论 ·
维护者通常 1 天内回复