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:
Glen Stampoultzis 2002-03-01 13:10:15 +00:00
parent f692c95cd4
commit cc50a990d1
3 changed files with 10 additions and 2 deletions

View File

@ -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) );
}
}

View File

@ -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));
}
}

View File

@ -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 );
}
}