Dates and timestamps outside years 0001 to 9999, and `infinity`, are read as garbage, with a probable out-of-bounds read
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with PqColumnDataSource::fetch_date() and PqColumnDataSource::convert_datetime() in src/PqColumnDataSource.cpp, then reproduce the examples against PostgreSQL. Confirm the suspected out-of-bounds read with Valgrind or ASan, and inspect existing date and timestamp tests. Done means infinity, years above 9999, and BC dates are handled as described and covered by tests; pull request #660 is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
date, timestamp and timestamptz values are parsed from fixed character positions (YYYY-MM-DD HH:MM:SS). Values in any other shape are read as garbage without a warning: infinity, -infinity, years above 9999 and BC dates. For 'infinity'::timestamp, an 8-character value, the parser reads at least 19 characters, so it reads past the end of the value; the result changes between runs and with the other columns of the query, which points to an out-of-bounds read. This is not Arrow-specific; Arrow results inherit it.
Location: RPostgres, PqColumnDataSource::fetch_date() and PqColumnDataSource::convert_datetime().
Reprex against the CRAN release. main at 41cd4be gives the same output except for the infinite timestamps, which differ between runs anyway (there: 63849-02-27 07:42:00 and 63849-03-26 06:50:00).
Sys.setenv(PGHOST = "localhost", PGPORT = "5432", PGUSER = "runner", PGPASSWORD = "test123", PGDATABASE = "testdb")
library(DBI)
con <- dbConnect(RPostgres::Postgres())
dbGetQuery(con, "SELECT 'infinity'::date AS a, '-infinity'::date AS b")
#> a b
#> 1 63849-01-15 3432-06-30
# Expected: Inf and -Inf (or NA)
# 'infinity' has 8 characters, the parser reads 19 or more: the result depends on what follows in memory
dbGetQuery(con, "SELECT 'infinity'::timestamp AS c")
#> c
#> 1 63848-11-09 19:12:00
dbGetQuery(con, "SELECT 1 AS x, 'infinity'::timestamp AS c, 'abc' AS y")
#> x c y
#> 1 1 63849-03-26 21:18:00 abc
dbGetQuery(con, "SELECT '-infinity'::timestamptz AS c, 'some other text' AS y")
#> c y
#> 1 3432-07-28 17:23:00 some other text
# Expected: Inf and -Inf (or NA), the same in every query
dbGetQuery(con, "SELECT '10000-01-01'::date AS a, '0044-03-15 BC'::date AS b")
#> a b
#> 1 997-04-27 44-03-15
# Expected: 10000-01-01 and -0043-03-15
dbGetQuery(con, "SELECT '10000-01-01 12:00'::timestamp AS a, '0044-03-15 12:00 BC'::timestamp AS b")
#> a b
#> 1 997-04-20 10:40:00 44-03-15 12:00:00
# Expected: 10000-01-01 12:00:00 and -0043-03-15 12:00:00
dbGetQuery(con, "SHOW server_version")
#> server_version
#> 1 16.15 (Ubuntu 16.15-0ubuntu0.24.04.1)
dbDisconnect(con)
as.data.frame(sessioninfo::package_info(c("RPostgres", "DBI"), dependencies = FALSE))[c("package", "ondiskversion", "source")]
#> package ondiskversion source
#> DBI DBI 1.3.0 RSPM
#> RPostgres RPostgres 1.4.10 RSPM (R 4.5.0)
Created on 2026-11-29 with reprex v2.1.1
- confirm the out-of-bounds read (for example with valgrind or ASan)
- fix
infinityand-infinity(map toInfand-Inf) - fix years above 9999 and BC dates (parse up to the first
-, honor theBCsuffix) - test
Severity: high (proposed, Kirill may change). High for the infinite timestamps (memory safety), medium for the other values.
Native Arrow support is coordinated in https://github.com/r-dbi/RPostgres/pull/631; it is not expected to fix this by construction, since it reuses the fetch path unless it parses the values itself.
- Ngôn ngữ chính
- R
- Star
- 345
- Fork
- 81
- Merge trung bình
- 8 giờ 21 phút
- Pull request đã merge (30 ngày)
- 18
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọ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 r-dbi/RPostgres
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
-
performance
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của r-dbi/RPostgres
Issue tương tự
-
Installation fails from source: missing libintl.h on macOS, undeclared R_typeToChar() on R 4.6Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vincentarelbundock/xtx#11 ·
-
Check that backends override both `dbFetchArrowChunk()` and `dbClearArrowChunk()`, or neitherĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
priority:low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
ichirio/rtfreporter#1166 ·
Maintainer thường phản hồi trong vòng 1 ngày