You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@daffodil.apache.org by GitBox <gi...@apache.org> on 2018/10/15 14:01:47 UTC
[GitHub] stevedlawrence closed pull request #124: Check for available data
before trying to parse binarySeconds or binaryMilliseconds
stevedlawrence closed pull request #124: Check for available data before trying to parse binarySeconds or binaryMilliseconds
URL: https://github.com/apache/incubator-daffodil/pull/124
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesDateTime1.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesDateTime1.scala
index 8f3f4e81b..8c89bcf24 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesDateTime1.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/PrimitivesDateTime1.scala
@@ -184,6 +184,12 @@ case class ConvertBinaryCalendarSecMilliParser(
def parse(start: PState): Unit = {
val dis = start.dataInputStream
+
+ if (!dis.isDefinedForLength(lengthInBits)) {
+ PENotEnoughBits(start, lengthInBits, dis.remainingBits)
+ return
+ }
+
val slong: Long = dis.getSignedLong(lengthInBits, start)
val cal = epochCal.clone.asInstanceOf[Calendar]
diff --git a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SequenceParserBases.scala b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SequenceParserBases.scala
index 1aa084c64..849b7d1c8 100644
--- a/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SequenceParserBases.scala
+++ b/daffodil-runtime1/src/main/scala/org/apache/daffodil/processors/parsers/SequenceParserBases.scala
@@ -237,12 +237,12 @@ abstract class OrderedSequenceParserBase(
case t: Throwable => {
if (pstate.isInUse(priorState)) {
markLeakCausedByException = true
+ pstate.discard(priorState)
if (!t.isInstanceOf[SchemaDefinitionDiagnosticBase] && !t.isInstanceOf[UnsuppressableException]) {
val stackTrace = new StringWriter()
t.printStackTrace(new PrintWriter(stackTrace))
Assert.invariantFailed("Exception thrown with mark not returned: " + t + "\nStackTrace:\n" + stackTrace)
}
- pstate.discard(priorState)
}
throw t
}
diff --git a/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/SimpleTypes.tdml b/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/SimpleTypes.tdml
index 4f8b01490..e398d3497 100644
--- a/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/SimpleTypes.tdml
+++ b/daffodil-test/src/test/resources/org/apache/daffodil/section05/simple_types/SimpleTypes.tdml
@@ -2407,6 +2407,36 @@
</tdml:errors>
</tdml:parserTestCase>
+ <tdml:parserTestCase name="dateTimeBin21" root="dateTimeBin"
+ model="SimpleTypes-binary" description="Section 5 Schema types-dateTime - DFDL-5-016R">
+
+ <tdml:document>
+ <tdml:documentPart type="bits">0000000 00000000 00000000 00111110</tdml:documentPart>
+ </tdml:document>
+ <tdml:errors>
+ <tdml:error>Parse Error</tdml:error>
+ <tdml:error>Insufficient bits</tdml:error>
+ <tdml:error>Needed 32</tdml:error>
+ <tdml:error>31 available</tdml:error>
+ </tdml:errors>
+ </tdml:parserTestCase>
+
+ <tdml:parserTestCase name="dateTimeBin22" root="dateTimeBin5"
+ model="SimpleTypes-binary" description="Section 5 Schema types-dateTime - DFDL-5-016R"
+ roundTrip="true">
+
+ <tdml:document>
+ <tdml:documentPart type="bits">0000000 00000000 00000000 00000000 00000000 00000000 00000000 00000001</tdml:documentPart>
+ </tdml:document>
+ <tdml:errors>
+ <tdml:error>Parse Error</tdml:error>
+ <tdml:error>Parse Error</tdml:error>
+ <tdml:error>Insufficient bits</tdml:error>
+ <tdml:error>Needed 64</tdml:error>
+ <tdml:error>63 available</tdml:error>
+ </tdml:errors>
+ </tdml:parserTestCase>
+
<tdml:parserTestCase name="dateBinBCD" root="dateBinBCD"
model="SimpleTypes-binary" description="Section 5 Schema types-dateTime - DFDL-5-016R"
roundTrip="true">
diff --git a/daffodil-test/src/test/scala/org/apache/daffodil/section05/simple_types/TestSimpleTypes.scala b/daffodil-test/src/test/scala/org/apache/daffodil/section05/simple_types/TestSimpleTypes.scala
index 0997a53b3..a67ad479b 100644
--- a/daffodil-test/src/test/scala/org/apache/daffodil/section05/simple_types/TestSimpleTypes.scala
+++ b/daffodil-test/src/test/scala/org/apache/daffodil/section05/simple_types/TestSimpleTypes.scala
@@ -191,6 +191,8 @@ class TestSimpleTypes {
@Test def test_dateTimeBin18() { runner.runOneTest("dateTimeBin18") }
@Test def test_dateTimeBin19() { runner.runOneTest("dateTimeBin19") }
@Test def test_dateTimeBin20() { runner.runOneTest("dateTimeBin20") }
+ @Test def test_dateTimeBin21() { runner.runOneTest("dateTimeBin21") }
+ @Test def test_dateTimeBin22() { runner.runOneTest("dateTimeBin22") }
@Test def test_dateBinBCD() { runner.runOneTest("dateBinBCD") }
@Test def test_dateBinBCD2() { runner.runOneTest("dateBinBCD2") }
@Test def test_dateBinBCD3() { runner.runOneTest("dateBinBCD3") }
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services