Changeset: 1ebbee3f0896 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/1ebbee3f0896 Added Files: sql/test/BugTracker-2023/Tests/parse_interval-crash-7412.test Modified Files: sql/server/sql_datetime.c sql/test/BugTracker-2023/Tests/All Branch: Dec2023 Log Message:
Fix crash when parsing invalid interval string. issue 7412. diffs (59 lines): diff --git a/sql/server/sql_datetime.c b/sql/server/sql_datetime.c --- a/sql/server/sql_datetime.c +++ b/sql/server/sql_datetime.c @@ -139,25 +139,29 @@ parse_interval_(mvc *sql, lng sign, cons switch (sk) { case imonth: if (val >= 12) { - snprintf(sql->errstr, ERRSIZE, _("Overflow detected in months (" LLFMT ")\n"), val); + if (sql) + snprintf(sql->errstr, ERRSIZE, _("Overflow detected in months (" LLFMT ")\n"), val); return -1; } break; case ihour: if (val >= 24) { - snprintf(sql->errstr, ERRSIZE, _("Overflow detected in hours (" LLFMT ")\n"), val); + if (sql) + snprintf(sql->errstr, ERRSIZE, _("Overflow detected in hours (" LLFMT ")\n"), val); return -1; } break; case imin: if (val >= 60) { - snprintf(sql->errstr, ERRSIZE, _("Overflow detected in minutes (" LLFMT ")\n"), val); + if (sql) + snprintf(sql->errstr, ERRSIZE, _("Overflow detected in minutes (" LLFMT ")\n"), val); return -1; } break; case isec: if (val >= 60000) { - snprintf(sql->errstr, ERRSIZE, _("Overflow detected in seconds (" LLFMT ")\n"), val); + if (sql) + snprintf(sql->errstr, ERRSIZE, _("Overflow detected in seconds (" LLFMT ")\n"), val); return -1; } break; diff --git a/sql/test/BugTracker-2023/Tests/All b/sql/test/BugTracker-2023/Tests/All --- a/sql/test/BugTracker-2023/Tests/All +++ b/sql/test/BugTracker-2023/Tests/All @@ -15,4 +15,5 @@ misc-crashes-7390 greatest-least-multi-arg-7391 union-query-7401 join-on-row_number-over-7403 +parse_interval-crash-7412 between-crash-7413 diff --git a/sql/test/BugTracker-2023/Tests/parse_interval-crash-7412.test b/sql/test/BugTracker-2023/Tests/parse_interval-crash-7412.test new file mode 100644 --- /dev/null +++ b/sql/test/BugTracker-2023/Tests/parse_interval-crash-7412.test @@ -0,0 +1,8 @@ +statement error GDK reported error: INETfromString: Error while parsing, unexpected string '::192.168.1.226' +SELECT CAST ( '::192.168.1.226' AS inet ) + +statement error 42000!Wrong format (::192.168.1.226) +SELECT CAST ( '::192.168.1.226' AS INTERVAL HOUR TO SECOND ) + +statement error 42000!Wrong format (::192.168.1.226) +SELECT CAST ( '::192.168.1.226' AS INTERVAL HOUR ( 3 ) TO SECOND ) _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org