bug: ListTypeFromJson hits undefined behavior when a list type has no "element"
維護者通常 2 天內回覆
已經有一個關聯 PR 被合併了。
- #997 來自 @LuciferYang —— 已合併
評估
研究方向
從 src/iceberg/json_serde.cc 中的 ListTypeFromJson 開始,它透過 const 存取器 json[kElement] 讀取元素型別。同一檔案中的 MapTypeFromJson 已經透過 GetJsonValue 讀取 key 和 value,因此為 kElement 複製這個模式。當缺少 "element" 的列表型別物件回傳 JsonParseError,而不是觸發未定義行為時即完成,可以用 issue 中的重現步驟驗證。
由索引模型根據 Issue 內容生成。
描述
Summary
ListTypeFromJson in src/iceberg/json_serde.cc reads the element type with the const json[kElement] accessor and never checks that the key exists. For a list type object without "element", nlohmann's const operator[] is undefined behavior: with assertions enabled it aborts on JSON_ASSERT(it != m_data.m_value.object->end()), and under NDEBUG it dereferences the end iterator.
Reproduction
auto json = R"({"type":"list","element-id":1,"element-required":true})"_json;
auto result = TypeFromJson(json);
// Debug build: Assertion failed: (it != m_data.m_value.object->end()), function operator[], file json.hpp
Impact
Every list type goes through TypeFromJson, so a schema with a list-typed field that lacks "element" hits this whether the list is top level or nested in a struct, map or list. SchemaFromJson reaches it when parsing table metadata schemas, the add-schema table update, and the REST CreateTableRequest. Per SECURITY-THREAT-MODEL.md catalog-supplied metadata is trusted input, so this is a robustness issue rather than a security one.
Proposed Fix
Read the key with GetJsonValue<nlohmann::json>(json, kElement), the way MapTypeFromJson reads key and value, so a missing key returns JsonParseError.
Raised in https://github.com/apache/iceberg-cpp/pull/982#pullrequestreview-5477946927.
- 主要語言
- C++
- 星號
- 226
- 分支
- 133
- 平均合併
- 5 天 10 小時
- 30 天內合併 PR
- 33
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
apache/iceberg-cpp 的其他 Issue
-
bug: ReferenceVisitor::GetReferencedFieldIds dereferences null on a bound COUNT(*)可能已有人在做 @LuciferYang 於 12 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
apache/iceberg-cpp#978 ·
維護者通常 2 天內回覆
-
bug: InMemoryCatalog skips the namespace existence check in CreateTable and RegisterTable可能已有人在做 @LuciferYang 於 12 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
apache/iceberg-cpp#977 ·
維護者通常 2 天內回覆
-
難度 4/5 3-5 天 新手友好度 35/100
apache/iceberg-cpp#1000 · 1 則留言 · 1 個 reaction ·
維護者通常 2 天內回覆
-
Support Iceberg table encryption (Java-compatible)可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 5/5 一週以上 新手友好度 8/100
apache/iceberg-cpp#988 · 1 則留言 ·
維護者通常 2 天內回覆
-
難度 5/5 一週以上 新手友好度 20/100
apache/iceberg-cpp#959 · 1 則留言 ·
維護者通常 2 天內回覆
查看 apache/iceberg-cpp 的全部 Issue
相似的 Issue
-
bug format I/O medium priority rt_lib
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
refactor
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 62/100
compiler-explorer/compiler-explorer#9272 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 65/100
-
難度 1/5 1 小時以內 新手友好度 76/100
維護者通常 1 天內回覆