miniscript icon indicating copy to clipboard operation
miniscript copied to clipboard

[C++ & C#] Miniscript aborts when `_dateStr` handles excessive number

Open Withered-Flower-0422 opened this issue 1 year ago • 4 comments

In cmd:

> _dateStr 1e20
PS C:\Users\13390>  // MiniScript aborts

In MM:

]_dateStr 1e14  // null
]_dateStr 1e15
7909-01-14 12:55:42  // wrong date
]_dateStr 1e16
2634-12-20 03:40:52  // wrong date

Withered-Flower-0422 avatar Jul 14 '24 08:07 Withered-Flower-0422

For C++, I think adding

if (errno == EOVERFLOW) return "";

after this line should fix it: https://github.com/JoeStrout/miniscript/blob/e85ec618a6ed11eb04d02a973e42315c19d426d5/MiniScript-cpp/src/DateTimeUtils.cpp#L34

(As for C#, don't know...)

marcgurevitx avatar Jul 14 '24 09:07 marcgurevitx

Seems like on Windows the problem was on this line (when _localtime64() returned NULL): https://github.com/JoeStrout/miniscript/blob/e85ec618a6ed11eb04d02a973e42315c19d426d5/MiniScript-cpp/src/DateTimeUtils.cpp#L16

Filed a PR

marcgurevitx avatar Jul 14 '24 11:07 marcgurevitx

Closing thanks to PR#162.

JoeStrout avatar Jul 28 '24 20:07 JoeStrout

Oops, that was a mistake. Meant to close #164. This one needs to stay open until we've addressed the same thing in the C# code.

JoeStrout avatar Jul 28 '24 20:07 JoeStrout