mirror of https://github.com/apache/poi.git
Fixed bug with byte overruns.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352124 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f692c95cd4
commit
cc50a990d1
|
@ -118,7 +118,7 @@ public class FooterRecord
|
|||
{
|
||||
field_1_footer_len = data[ 0 + offset ];
|
||||
field_2_footer = new String(data, 1 + offset,
|
||||
( int ) field_1_footer_len);
|
||||
LittleEndian.ubyteToInt( field_1_footer_len) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public class HeaderRecord
|
|||
{
|
||||
field_1_header_len = data[ 0 + offset ];
|
||||
field_2_header = new String(data, 1 + offset,
|
||||
( int ) field_1_header_len);
|
||||
LittleEndian.ubyteToInt(field_1_header_len));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -498,4 +498,12 @@ public class LittleEndian
|
|||
v >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an 'unsigned' byte to an integer. ie, don't carry across the sign.
|
||||
*/
|
||||
public static int ubyteToInt(byte b)
|
||||
{
|
||||
return ((b & 0x80) == 0 ? (int)b : (int)(b & (byte)0x7f) + 0x80 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue