JoeStrout / miniscript

source code of both C# and C++ implementations of the MiniScript scripting language
MIT License
272 stars 63 forks source link

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

Open Withered-Flower-0422 opened 1 month ago

Withered-Flower-0422 commented 1 month ago

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
marcgurevitx commented 1 month ago

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 commented 1 month ago

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

JoeStrout commented 1 month ago

Closing thanks to PR#162.

JoeStrout commented 1 month ago

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.