ASF Bugzilla – Attachment 29668 Details for
Bug 54233
When attached testing code is executed against the attached document, it generates the exception here under.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch
UnicodeString.java.patch (text/plain), 1.90 KB, created by
Philippe Dubois
on 2012-12-03 09:58:06 UTC
(
hide
)
Description:
Proposed patch
Filename:
MIME Type:
Creator:
Philippe Dubois
Created:
2012-12-03 09:58:06 UTC
Size:
1.90 KB
patch
obsolete
>Index: UnicodeString.java >=================================================================== >--- UnicodeString.java (revision 1407532) >+++ UnicodeString.java (working copy) >@@ -35,6 +35,26 @@ > { > int length = LittleEndian.getInt( data, offset ); > >+ // If the length looks wrong, this might be because the offset is expected to be on a >+ // 4 byte boundary. Try changing it rather than getting an ArrayIndexOutOfBoundsException >+ // from LittleEndian.getByteArray. Also avoids creating a large byte[] if this is the case. >+ if (!validLength( length, data, offset + LittleEndian.INT_SIZE )) >+ { >+ if (offset % 4 != 0) >+ { >+ offset += 2; >+ } >+ >+ length = LittleEndian.getInt( data, offset ); >+ >+ if (!validLength(length, data, offset + LittleEndian.INT_SIZE)) >+ { >+ throw new IllegalPropertySetDataException( >+ "UnicodeString started at offset #" + offset >+ + " is not NULL-terminated" ); >+ } >+ } >+ > if ( length == 0 ) > { > _value = new byte[0]; >@@ -43,13 +63,18 @@ > > _value = LittleEndian.getByteArray( data, offset > + LittleEndian.INT_SIZE, length * 2 ); >- >- if ( _value[length * 2 - 1] != 0 || _value[length * 2 - 2] != 0 ) >- throw new IllegalPropertySetDataException( >- "UnicodeString started at offset #" + offset >- + " is not NULL-terminated" ); > } > >+ private boolean validLength(int length, byte[] data, int offset) { >+ if (length == 0) >+ { >+ return true; >+ } >+ int size = length * 2; >+ offset += size; >+ return offset < data.length && size >= 0 && data[offset-1] == 0 && data[offset-2] == 0; >+ } >+ > int getSize() > { > return LittleEndian.INT_SIZE + _value.length;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 54233
:
29666
|
29667
| 29668