Quantcast
Channel: Excel Data Reader - Read Excel files in .NET
Viewing all articles
Browse latest Browse all 448

Created Unassigned: XlsBiffRecord.ReadStrings does not handle all cases correctly [12931]

$
0
0
When a continuation breaks comes just before (or in?) the tail/postfix part of the XlsFormattedUnicodeString the ReadStrings method doesn't handle this case correctly.

You have to check if there are still chars to read.
int charsLeft = (int)(len - (last - prefix - offset) / (str.IsMultiByte ? 2 : 1));

If charsLeft >0 then the available code handles the case correctly.

If charsLeft == 0 then the available code still reads the current string but fails when reading the next string because the new offset is wrong.

When charsLeft == 0 the new offset should be
offset = contoffset + 4 + size - last + offset;
And the temp buffer
Buffer.BlockCopy(m_bytes, (int)contoffset + 4, buff, (int)(last - offset), (int)(size - last + offset));
There is no encoding byte?

This code addition worked in my case (xls file was too big to send as attachment).
After the changes all the strings were read correctly.

No errors are thrown when reading the SST.
No errors are thrown when getting strings out of the SST when the index exceeds the bounds of the array (empty string is returned).
So I only detected this issue when running queries on the migrated data (Excel to SQL).

I didn't test other cases, e.g. continuation breaks in the head/prefix part, because I don't know if this is even possible.

Viewing all articles
Browse latest Browse all 448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>