Alternative map sorting
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- c
- 领域
- embedded-iot
调研方向
从 cborvalidation.c 第 475 行附近开始,检查现有的 map 排序和唯一性 flags。明确替代排序应取代还是补充当前行为,然后定义预期的顺序、key 处理方式以及重复 key 的行为;完成取决于对设计和实现范围达成一致。
由索引模型根据 Issue 内容生成。
描述
Hello,
I've been looking into the CBOR validator and how maps are considered as sorted or not. In another project, I have previously been using another serialization standard that strictly defines maps in another way. Such as keys must only be strings, keys must be stored in lexicographical order and that no duplicates are allowed. Now we are looking into changing to cbor.
The CBOR specification does not strictly specifies what an ordered map is, but recommends that they should also be sorted in length. Meaning that "aa" > "b".
The alternatives are:
- Change sorting specification in our protocol (to order the fields like CBOR specification recommends)
- Not having sorted maps
- Finding/adapting a cbor library to allow for alternative sorting
Sorting is nice since is allows for linear parsing. Since we rely on this, we cannot directly swap to cbor. I would like to start a discussion of supporting an alternative sorting in tinycbor.
Wrote a short proof of concept for this (removes old sorting behavior) cborvalidation.c:475:
if (flags & CborValidateMapIsSorted) {
if (previous) {
uint64_t len1, len2;
const uint8_t *ptr;
/* extract the two lengths */
ptr = previous;
_cbor_value_extract_number(&ptr, it->parser->end, &len1);
ptr = current;
_cbor_value_extract_number(&ptr, it->parser->end, &len2);
size_t bytelen1 = (size_t)(previous_end - previous);
size_t bytelen2 = (size_t)(it->ptr - current);
/*
* Offset of actual key value (not including type information) is bytelenX - lenX??
* What if key value is indefinite??
*/
int r = memcmp(&previous[bytelen1 - len1], ¤t[bytelen2 - len2], len1 <= len2 ? len1 : len2);
if (r == 0 && len1 != len2)
r = len1 < len2 ? -1 : +1;
if (r > 0)
return CborErrorMapNotSorted;
if (r == 0 && (flags & CborValidateMapKeysAreUnique) == CborValidateMapKeysAreUnique)
return CborErrorMapKeysNotUnique;
}
Would it be possible to add a flag that would allow for this kind of sorting?
- 主要语言
- 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 于 13 天前认领。 未关闭
难度 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
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
ChrisTitusTech/dwm-titus#397 ·
维护者通常 1 天内回复
-
good first issue help wanted language:fr translation
难度 1/5 1-3 小时 新手友好度 85/100
mrvi0/cli-cheatsheet#160 ·
-
Test modules use volatile int for cross-thread flags instead of atomics可能已有人在做 @rahimuddin140 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
valkey-io/valkey#4899 · 1 条评论 ·
维护者通常 2 天内回复
-
Profiler (Remotery) leaks a socket for every connection that fails the WebSocket handshake可能已有人在做 @rthery 今天认领。 未关闭triage
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
Symlink in release archive attempts traversal可能已有人在做 @Tiancheng-Xu 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复