From 85d7c078cba5b0dcd37c28ed62920af1fc9f6566 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Fri, 4 Oct 2013 02:39:47 +0000 Subject: Make reading long value columns more lenient (MEMO/OLE) git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/branches/jackcess-1.2.14@813 f203690c-595d-4dc9-a70b-905162fa7fd2 --- src/changes/changes.xml | 3 +++ src/java/com/healthmarketscience/jackcess/Column.java | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index a019ca8..e47124f 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -8,6 +8,9 @@ Ignore invalid column usage map definitions. + + Make reading long value columns more lenient (MEMO/OLE). + diff --git a/src/java/com/healthmarketscience/jackcess/Column.java b/src/java/com/healthmarketscience/jackcess/Column.java index 69412a8..4652e5f 100644 --- a/src/java/com/healthmarketscience/jackcess/Column.java +++ b/src/java/com/healthmarketscience/jackcess/Column.java @@ -931,6 +931,15 @@ public class Column implements Comparable { // 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 { @@ -954,6 +963,15 @@ public class Column implements Comparable { short rowStart = Table.findRowStart(lvalPage, rowNum, getFormat()); short rowEnd = Table.findRowEnd(lvalPage, rowNum, getFormat()); + 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]; + } + + if((rowEnd - rowStart) != length) { throw new IOException("Unexpected lval row length"); } -- cgit v1.2.3