@@ -81,6 +81,38 @@ TEST(TestTime, TestCastDateInvalidUnterminated) {
8181 context.Reset ();
8282}
8383
84+ TEST (TestTime, TestCastTimestampInvalidUnterminated) {
85+ ExecutionContext context;
86+ int64_t context_ptr = reinterpret_cast <int64_t >(&context);
87+
88+ // castTIMESTAMP_utf8 reaches the same set_error_for_date helper, so exercise
89+ // the over-read path from that entry point with an unterminated buffer too.
90+ const std::string value = " 2000-01-01 24:00:00" ;
91+ const auto length = static_cast <int32_t >(value.size ());
92+ std::unique_ptr<char []> input (new char [length]);
93+ std::memcpy (input.get (), value.data (), length);
94+
95+ EXPECT_EQ (castTIMESTAMP_utf8 (context_ptr, input.get (), length), 0 );
96+ EXPECT_EQ (context.get_error (),
97+ " Not a valid time for timestamp value 2000-01-01 24:00:00" );
98+ context.Reset ();
99+ }
100+
101+ TEST (TestTime, TestCastTimeInvalidUnterminated) {
102+ ExecutionContext context;
103+ int64_t context_ptr = reinterpret_cast <int64_t >(&context);
104+
105+ // castTIME_utf8 reaches set_error_for_date as well.
106+ const std::string value = " 24H00H00" ;
107+ const auto length = static_cast <int32_t >(value.size ());
108+ std::unique_ptr<char []> input (new char [length]);
109+ std::memcpy (input.get (), value.data (), length);
110+
111+ EXPECT_EQ (castTIME_utf8 (context_ptr, input.get (), length), 0 );
112+ EXPECT_EQ (context.get_error (), " Invalid character in time 24H00H00" );
113+ context.Reset ();
114+ }
115+
84116TEST (TestTime, TestCastTimestamp) {
85117 ExecutionContext context;
86118 int64_t context_ptr = reinterpret_cast <int64_t >(&context);
0 commit comments