提交 ddbfdbc4 authored 作者: noelgrandin's avatar noelgrandin

Make org.h2.util.ScriptReader throw a better exception when handling broken…

Make org.h2.util.ScriptReader throw a better exception when handling broken scripts which generate extremely large statements.
上级 60222856
...@@ -74,6 +74,8 @@ Change Log ...@@ -74,6 +74,8 @@ Change Log
</li><li>Make Server#openBrowser respect the $BROWSER environment variable. Add "chromium" to the list of browsers tried. </li><li>Make Server#openBrowser respect the $BROWSER environment variable. Add "chromium" to the list of browsers tried.
Patch from Felix Kaiser. Patch from Felix Kaiser.
</li><li>Fix to org.h2.util.ScriptReader when handling unclosed block comments. </li><li>Fix to org.h2.util.ScriptReader when handling unclosed block comments.
</li><li>Make org.h2.util.ScriptReader throw a better exception when handling broken scripts which generate
extremely large statements.
</li></ul> </li></ul>
<h2>Version 1.3.173 (2013-07-28)</h2> <h2>Version 1.3.173 (2013-07-28)</h2>
......
...@@ -237,6 +237,12 @@ public class ScriptReader { ...@@ -237,6 +237,12 @@ public class ScriptReader {
if (keep > 0) { if (keep > 0) {
char[] src = buffer; char[] src = buffer;
if (keep + Constants.IO_BUFFER_SIZE > src.length) { if (keep + Constants.IO_BUFFER_SIZE > src.length) {
// protect against NegativeArraySizeException
if (src.length >= Integer.MAX_VALUE / 2) {
throw new IOException("error in parsing script, statement size exceeds 1G, " +
"first 80 characters of statement looks like: " +
new String(buffer,bufferStart,80));
}
buffer = new char[src.length * 2]; buffer = new char[src.length * 2];
} }
System.arraycopy(src, bufferStart, buffer, 0, keep); System.arraycopy(src, bufferStart, buffer, 0, keep);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论