Bug 58069 - Biff8RC4 xorShort returns wrong value for unsigned shorts
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1687146 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6f80ba5516
commit
057768994e
@ -95,7 +95,7 @@ public final class Biff8DecryptingStream implements BiffHeaderInput, LittleEndia
|
||||
|
||||
|
||||
public int readUByte() {
|
||||
return _cipher.xorByte(_le.readUByte());
|
||||
return readByte() & 0xFF;
|
||||
}
|
||||
public byte readByte() {
|
||||
return (byte) _cipher.xorByte(_le.readUByte());
|
||||
@ -103,7 +103,7 @@ public final class Biff8DecryptingStream implements BiffHeaderInput, LittleEndia
|
||||
|
||||
|
||||
public int readUShort() {
|
||||
return _cipher.xorShort(_le.readUShort());
|
||||
return readShort() & 0xFFFF;
|
||||
}
|
||||
public short readShort() {
|
||||
return (short) _cipher.xorShort(_le.readUShort());
|
||||
|
@ -96,9 +96,21 @@ public final class TestBiff8DecryptingStream {
|
||||
}
|
||||
|
||||
public void confirmShort(int expVal) {
|
||||
cmp(HexDump.shortToHex(expVal), HexDump.shortToHex(_bds.readUShort()));
|
||||
cmp(HexDump.shortToHex(expVal), HexDump.shortToHex(_bds.readShort()));
|
||||
}
|
||||
|
||||
public void confirmUShort(int expVal) {
|
||||
cmp(HexDump.shortToHex(expVal), HexDump.shortToHex(_bds.readUShort()));
|
||||
}
|
||||
|
||||
public short readShort() {
|
||||
return _bds.readShort();
|
||||
}
|
||||
|
||||
public int readUShort() {
|
||||
return _bds.readUShort();
|
||||
}
|
||||
|
||||
public void confirmInt(int expVal) {
|
||||
cmp(HexDump.intToHex(expVal), HexDump.intToHex(_bds.readInt()));
|
||||
}
|
||||
@ -166,6 +178,15 @@ public final class TestBiff8DecryptingStream {
|
||||
st.rollForward(0x0C04, 0x0FF8);
|
||||
st.confirmLong(0x6AA2D5F6B975D10CL);
|
||||
st.confirmLong(0x34248ADF7ED4F029L);
|
||||
// check for signed/unsigned shorts #58069
|
||||
st.rollForward(0x1008, 0x7213);
|
||||
st.confirmUShort(0xFFFF);
|
||||
st.rollForward(0x7215, 0x1B9AD);
|
||||
st.confirmShort(-1);
|
||||
st.rollForward(0x1B9AF, 0x37D99);
|
||||
assertEquals(0xFFFF, st.readUShort());
|
||||
st.rollForward(0x37D9B, 0x4A6F2);
|
||||
assertEquals(-1, st.readShort());
|
||||
st.assertNoErrors();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user