2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-02-17 01:42:17 +00:00

Improved error detection in DATETIME bin deseriaiz

Now DATETIMEs with invalid dates and invalid hours/mins/secs/micros are
considered an error. Added tests.
This commit is contained in:
ruben
2020-05-11 09:20:22 +01:00
parent 6c4364d246
commit fdf2662b60
2 changed files with 31 additions and 20 deletions

View File

@@ -149,22 +149,26 @@ std::vector<err_binary_value_testcase> make_datetime_cases(
{
return {
{ "empty", {}, type, errc::incomplete_message },
{ "incomplete_date", {0x04, 0x09, 0x27, 0x01}, type, errc::incomplete_message },
{ "no_hours_mins_secs", {0x07, 0x09, 0x27, 0x01, 0x01}, type, errc::incomplete_message },
{ "no_mins_secs", {0x07, 0x09, 0x27, 0x01, 0x01, 0x01}, type, errc::incomplete_message },
{ "no_secs", {0x07, 0x09, 0x27, 0x01, 0x01, 0x01, 0x01}, type, errc::incomplete_message },
{ "no_micros", {0x0b, 0x09, 0x27, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00},
{ "incomplete_date", {0x04, 0x09, 0x27, 0x01}, type, errc::incomplete_message },
{ "no_hours_mins_secs", {0x07, 0x09, 0x27, 0x01, 0x01}, type, errc::incomplete_message },
{ "no_mins_secs", {0x07, 0x09, 0x27, 0x01, 0x01, 0x01}, type, errc::incomplete_message },
{ "no_secs", {0x07, 0x09, 0x27, 0x01, 0x01, 0x01, 0x01}, type, errc::incomplete_message },
{ "no_micros", {0x0b, 0x09, 0x27, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00},
type, errc::incomplete_message },
{ "date_gt_max", {0x0b, 0xff, 0xff, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_hour", {0x0b, 0xda, 0x07, 0x01, 0x01, 24, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_hour_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0xff, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_min", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 60, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_min_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0xff, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_sec", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 60, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_sec_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0xff, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_micro", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x40, 0x42, 0xf4, 0x00}, type }, // 1M
{ "invalid_micro_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0xff, 0xff, 0xff, 0xff}, type },
{ "protocol_max", {0xff, 0xff, 0xff, 12, 31, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, type }, // make date valid
{ "date_gt_max", {0x0b, 0xff, 0xff, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_hour", {0x0b, 0xda, 0x07, 0x01, 0x01, 24, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_hour_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0xff, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_hour_invalid_date", {0x0b, 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_min", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 60, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_min_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0xff, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_min_invalid_date", {0x0b, 0x00, 0x00, 0x00, 0x00, 0x17, 0xff, 0x3b, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_sec", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 60, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_sec_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0xff, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_sec_invalid_date", {0x0b, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0xff, 0x56, 0xc3, 0x0e, 0x00}, type },
{ "invalid_micro", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0x40, 0x42, 0xf4, 0x00}, type }, // 1M
{ "invalid_micro_max", {0x0b, 0xda, 0x07, 0x01, 0x01, 0x17, 0x01, 0x3b, 0xff, 0xff, 0xff, 0xff}, type },
{ "invalid_micro_invalid_date", {0x0b, 0x00, 0x00, 0x00, 0x00, 0x17, 0x01, 0x3b, 0xff, 0xff, 0xff, 0xff}, type },
{ "protocol_max", {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, type }
};
}