Skip to content

Commit c855de1

Browse files
authored
Check for non-finite double values in SQLite Julian date parsing (#37619)
1 parent 94af0ee commit c855de1

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

src/Microsoft.Data.Sqlite.Core/Properties/Resources.Designer.cs

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Microsoft.Data.Sqlite.Core/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174
<data name="NoData" xml:space="preserve">
175175
<value>No data exists for the row/column.</value>
176176
</data>
177+
<data name="NonFiniteDoubleJulianDateValue" xml:space="preserve">
178+
<value>Values representing Julian dates must be finite double values.</value>
179+
</data>
177180
<data name="ParallelTransactionsNotSupported" xml:space="preserve">
178181
<value>SqliteConnection does not support nested transactions.</value>
179182
</data>

src/Microsoft.Data.Sqlite.Core/SqliteValueReader.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,11 @@ protected virtual string GetOnNullErrorMsg(int ordinal)
435435

436436
private static DateTime FromJulianDate(double julianDate)
437437
{
438+
if (double.IsNaN(julianDate) || double.IsInfinity(julianDate) || double.IsNegativeInfinity(julianDate))
439+
{
440+
throw new InvalidOperationException(Resources.NonFiniteDoubleJulianDateValue);
441+
}
442+
438443
// computeYMD
439444
var iJD = (long)(julianDate * 86400000.0 + 0.5);
440445
var Z = (int)((iJD + 43200000) / 86400000);

0 commit comments

Comments
 (0)