UnmarshalTWKB decodes a huge element count as an empty geometry
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu với UnmarshalTWKB và bốn hàm nextMultiPoint, nextMultiLineString, nextMultiPolygon và nextGeometryCollection, các hàm này đọc số đếm dưới dạng uint64 và lặp theo int(count). Sao chép phép so sánh số byte còn lại đang dùng trong parsePointArray và parseIDList vào bốn hàm đó, trước các vòng lặp của chúng. Sau đó, mở rộng TestUnmarshalTWKBHugeCount với một trường hợp cho mỗi kiểu, dùng các đầu vào hex trong issue, và xác nhận chúng trả về lỗi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
UnmarshalTWKB returns an empty geometry rather than an error when a MultiPoint, MultiLineString, MultiPolygon or GeometryCollection declares 2^63 or more elements. This reproduces on master at a5aec8d on a 64-bit platform.
| Input | Result |
|---|---|
0400ffffffffffffffffff01 |
MULTIPOINT EMPTY |
0500ffffffffffffffffff01 |
MULTILINESTRING EMPTY |
0600ffffffffffffffffff01 |
MULTIPOLYGON EMPTY |
0700ffffffffffffffffff01 |
GEOMETRYCOLLECTION EMPTY |
0700ffffffffffffffffff0101000204 |
GEOMETRYCOLLECTION EMPTY |
Each input is a type byte, a metadata header without any flags set, and the varint for 2^64-1. The last input has a POINT(1 2) after the count, which is ignored.
Cause
The count is read as a uint64. nextMultiPoint, nextMultiLineString, nextMultiPolygon and nextGeometryCollection then loop with for i := 0; i < int(count); i++. A count of 2^63 or more converts to a negative int, so the loop body never runs. A count of 2^63-1 is rejected, because the first element can't be read from the remaining input.
parsePointArray and parseIDList compare the count with the remaining buffer size before narrowing it, and TestUnmarshalTWKBHugeCount covers both. That is why a huge point count in a LineString or a polygon ring is rejected, and why the inputs above are rejected when the ID list flag is set.
Likely fix
Make the same comparison in the four functions before the loop. Every element takes at least one byte, so a count larger than the number of remaining bytes can't be valid. TestUnmarshalTWKBHugeCount can then get a case for each of the four types.
- Ngôn ngữ chính
- Go
- Star
- 176
- Fork
- 27
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của peterstace/simplefeatures
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
peterstace/simplefeatures#726 ·
-
bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
peterstace/simplefeatures#724 ·
-
cleanup
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
peterstace/simplefeatures#722 ·
-
bug
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 45/100
peterstace/simplefeatures#721 ·
-
jtsport
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
peterstace/simplefeatures#700 ·
Tất cả issue của peterstace/simplefeatures
Issue tương tự
-
tld-snapshot
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
awslabs/ferret-scan#1064 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Đang mởenhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
DaoCloud/DaoCloud-docs#7839 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Ignore entry for RUSTSEC-2026-0002 no longer matches anything (`lru` is no longer in `Cargo.lock`)Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
influxdata/influxdb#27767 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support AlienVault OTX API keysĐang mởType: Enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
projectdiscovery/urlfinder#167 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
gojue/ecapture#1100 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày