Skip to content

Commit 53725e3

Browse files
cppguruGitHub Enterprise
authored andcommitted
Fix ASSERT_SAFE from bad BER date. (#4732)
1 parent e5ec57f commit 53725e3

File tree

2 files changed

+198
-187
lines changed

2 files changed

+198
-187
lines changed

groups/bal/balber/balber_berutil.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,11 @@ int BerUtil_DatetimeImpUtil::getExtendedBinaryDatetimeValue(
20012001
bdlt::ProlepticDateImpUtil::serialToYmd(
20022002
&year, &month, &day, daysSince0001Jan01);
20032003

2004+
// Make sure that the date actually exists before trying to create it
2005+
if (!bdlt::SerialDateImpUtil::isValidYearMonthDay(year, month, day)) {
2006+
return -1; // RETURN
2007+
}
2008+
20042009
const bdlt::Date date(year, month, day);
20052010

20062011
bsls::Types::Int64 microsecondsSinceMidnight;
@@ -2202,6 +2207,11 @@ int BerUtil_DatetimeImpUtil::getExtendedBinaryDatetimeTzValue(
22022207
bdlt::ProlepticDateImpUtil::serialToYmd(
22032208
&year, &month, &day, daysSince0001Jan01);
22042209

2210+
// Make sure that Date think it's actually valid before trying to create it
2211+
if (!bdlt::SerialDateImpUtil::isValidYearMonthDay(year, month, day)) {
2212+
return -1; // RETURN
2213+
}
2214+
22052215
const bdlt::Date date(year, month, day);
22062216

22072217
bsls::Types::Int64 microsecondsSinceMidnight;

0 commit comments

Comments
 (0)