From 1adb6ea69dc29d01e080b059d625a27a8f3e75c0 Mon Sep 17 00:00:00 2001 From: James Ahlborn Date: Fri, 4 Oct 2013 02:40:42 +0000 Subject: [PATCH] Make reading long value columns more lenient (MEMO/OLE) git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@814 f203690c-595d-4dc9-a70b-905162fa7fd2 --- src/changes/changes.xml | 6 ++++++ .../jackcess/impl/ColumnImpl.java | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 94a241d..b9d3e64 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -11,6 +11,9 @@ Ignore invalid column usage map definitions. + + Make reading long value columns more lenient (MEMO/OLE). + @@ -23,6 +26,9 @@ Ignore invalid column usage map definitions. + + Make reading long value columns more lenient (MEMO/OLE). + diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java index 8f808cb..65b276f 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/ColumnImpl.java @@ -671,6 +671,15 @@ public class ColumnImpl implements Column, 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 { @@ -694,8 +703,12 @@ public class ColumnImpl implements Column, Comparable { 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); -- 2.39.5