提交 500c9239 authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

Issue 598: parser fails on timestamp "24:00:00.1234" - prevent the creation of…

Issue 598: parser fails on timestamp "24:00:00.1234" - prevent the creation of out-of-range time values.
上级 b02f651e
...@@ -32,6 +32,7 @@ Change Log ...@@ -32,6 +32,7 @@ Change Log
</li><li>In version 1.4.184, a bug was introduced that broke queries </li><li>In version 1.4.184, a bug was introduced that broke queries
that have both joins and wildcards, for example: that have both joins and wildcards, for example:
select * from dual join(select x from dual) on 1=1 select * from dual join(select x from dual) on 1=1
</li><li>Issue 598: parser fails on timestamp "24:00:00.1234" - prevent the creation of out-of-range time values.
</li></ul> </li></ul>
<h2>Version 1.4.185 Beta (2015-01-16)</h2> <h2>Version 1.4.185 Beta (2015-01-16)</h2>
......
...@@ -56,7 +56,7 @@ public class ValueDecimal extends Value { ...@@ -56,7 +56,7 @@ public class ValueDecimal extends Value {
private ValueDecimal(BigDecimal value) { private ValueDecimal(BigDecimal value) {
if (value == null) { if (value == null) {
throw new IllegalArgumentException(); throw new IllegalArgumentException("null");
} else if (!value.getClass().equals(BigDecimal.class)) { } else if (!value.getClass().equals(BigDecimal.class)) {
throw DbException.get(ErrorCode.INVALID_CLASS_2, throw DbException.get(ErrorCode.INVALID_CLASS_2,
BigDecimal.class.getName(), value.getClass().getName()); BigDecimal.class.getName(), value.getClass().getName());
......
...@@ -8,7 +8,6 @@ package org.h2.value; ...@@ -8,7 +8,6 @@ package org.h2.value;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Time; import java.sql.Time;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.util.DateTimeUtils; import org.h2.util.DateTimeUtils;
...@@ -34,6 +33,9 @@ public class ValueTime extends Value { ...@@ -34,6 +33,9 @@ public class ValueTime extends Value {
private final long nanos; private final long nanos;
private ValueTime(long nanos) { private ValueTime(long nanos) {
if (nanos < 0 || nanos >= 24L * 60 * 60 * 1000 * 1000) {
throw new IllegalArgumentException("timeNanos out of range " + nanos);
}
this.nanos = nanos; this.nanos = nanos;
} }
......
...@@ -50,6 +50,9 @@ public class ValueTimestamp extends Value { ...@@ -50,6 +50,9 @@ public class ValueTimestamp extends Value {
private ValueTimestamp(long dateValue, long timeNanos) { private ValueTimestamp(long dateValue, long timeNanos) {
this.dateValue = dateValue; this.dateValue = dateValue;
if (timeNanos < 0 || timeNanos >= 24L * 60 * 60 * 1000 * 1000) {
throw new IllegalArgumentException("timeNanos out of range " + timeNanos);
}
this.timeNanos = timeNanos; this.timeNanos = timeNanos;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论