]> source.dussan.org Git - jackcess.git/commitdiff
Make reading long value columns more lenient (MEMO/OLE)
authorJames Ahlborn <jtahlborn@yahoo.com>
Fri, 4 Oct 2013 02:40:42 +0000 (02:40 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Fri, 4 Oct 2013 02:40:42 +0000 (02:40 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@814 f203690c-595d-4dc9-a70b-905162fa7fd2

src/changes/changes.xml
src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java

index 94a241daf59b8c756be4dbd1ae79a14b41555ad1..b9d3e64fd26896df7b0db8f73420dd13db988e88 100644 (file)
@@ -11,6 +11,9 @@
       <action dev="jahlborn" type="fix" system="SourceForge2" issue="97">
         Ignore invalid column usage map definitions.
       </action>
+      <action dev="jahlborn" type="fix">
+        Make reading long value columns more lenient (MEMO/OLE).
+      </action>
     </release>
     <release version="2.0.0" date="2013-08-26">
       <action dev="jahlborn" type="update">
@@ -23,6 +26,9 @@
       <action dev="jahlborn" type="fix" system="SourceForge2" issue="97">
         Ignore invalid column usage map definitions.
       </action>
+      <action dev="jahlborn" type="fix">
+        Make reading long value columns more lenient (MEMO/OLE).
+      </action>
     </release>    
     <release version="1.2.14.2" date="2013-08-25">
       <action dev="jahlborn" type="fix" system="SourceForge2" issue="96">
index 8f808cbdedcdf77afee1ccf48d2e1fbadea792eb..65b276f0f13dc6113803168d0b6c47529c94eaaa 100644 (file)
@@ -671,6 +671,15 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl> {
       // inline long value
       def.getInt();  //Skip over lval_dp
       def.getInt();  //Skip over unknown
+
+      int rowLen = def.remaining();
+      if(rowLen < length) {
+        // warn the caller, but return whatever we can
+        LOG.warn(getName() + " value may be truncated: expected length " + 
+                 length + " found " + rowLen);
+        rtn = new byte[rowLen];
+      }
+
       def.get(rtn);
 
     } else {
@@ -694,8 +703,12 @@ public class ColumnImpl implements Column, Comparable<ColumnImpl> {
           short rowStart = TableImpl.findRowStart(lvalPage, rowNum, getFormat());
           short rowEnd = TableImpl.findRowEnd(lvalPage, rowNum, getFormat());
 
-          if((rowEnd - rowStart) != length) {
-            throw new IOException("Unexpected lval row length");
+          int rowLen = rowEnd - rowStart;
+          if(rowLen < length) {
+            // warn the caller, but return whatever we can
+            LOG.warn(getName() + " value may be truncated: expected length " + 
+                     length + " found " + rowLen);
+            rtn = new byte[rowLen];
           }
         
           lvalPage.position(rowStart);