Retain a limit on both ends, mark where we might return a null instead.

This commit is contained in:
Andy Reagan
2021-12-03 15:23:31 -05:00
parent c6ab656741
commit 898e880e87

View File

@@ -894,10 +894,9 @@ mdb_date_to_tm(double td, struct tm *t)
long yr, q;
const int *cal;
// if you want to limit 1900--2700, do this
// but it's not necessary
// if (td < 0.0 || td > 1e6) // About 2700 AD
// return;
// limit to ~1100AD--2700A to protect from overflow
if (td < -1e6 || td > 1e6)
return;
yr = 1;
day = (long)(td);
@@ -947,6 +946,8 @@ mdb_date_to_string(MdbHandle *mdb, const char *fmt, void *buf, int start)
mdb_date_to_tm(td, &t);
// check if t is still unchanged, return empty string?
strftime(text, mdb->bind_size, mdb->date_fmt, &t);
return text;