Author: max
Date: 2007-09-06 13:45:28 -0700 (Thu, 06 Sep 2007)
New Revision: 6391
Modified:
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/utils/FileUtils.java
Log:
Change 20070906-maxcarlson-V by [EMAIL PROTECTED] on 2007-09-06 13:00:25 PDT
in /Users/maxcarlson/openlaszlo/waffleconeclean
for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone
Summary: Fix possible null dereference in FileUtils.stripByteOrderMark()
New Features:
Bugs Fixed: LPP-4583 - Improve compiler and caching performance
Technical Reviewer: promanik
QA Reviewer: ptw
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details: Prevent a possible null dereference in stripByteOrderMark() by adding
a try/catch statement.
Tests: IWFM
Modified:
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/utils/FileUtils.java
===================================================================
---
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/utils/FileUtils.java
2007-09-06 20:45:02 UTC (rev 6390)
+++
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/utils/FileUtils.java
2007-09-06 20:45:28 UTC (rev 6391)
@@ -240,36 +240,40 @@
* @return the count of characters to skip
*/
public static int stripByteOrderMark (byte[] raw) {
- // We need to peek at the stream and if the first three chars
- // are a UTF-8 or UTF-16 encoded BOM (byte order mark) we will
- // discard them.
- int c1 = ((int) raw[0]) & 0xff;
- int c2 = ((int) raw[1]) & 0xff;
- int c3 = ((int) raw[2]) & 0xff;
- int count = 0;
- if (c1 == 0xFF & c2 == 0xFE) {
- // UTF16 Big Endian BOM
- // discard the first two chars
-// pbis.unread(c3);
-// return "UTF-16BE";
- return 2;
- } else if (c1 == 0xFE & c2 == 0xFF) {
- // UTF16 Little Endian BOM
- // discard the first two chars
-// pbis.unread(c3);
-// return "UTF-16LE";
- return 2;
- } else if (c1 == 0xEF && c2 == 0xBB && c3 == 0xBF) {
-// // UTF-8 BOM
-// // discard all three chars
-// return "UTF-8";
- return 3;
- } else {
- // Otherwise put back the chars we just read and proceed
-// pbis.unread(c3);
-// pbis.unread(c2);
-// pbis.unread(c1);
-// return null;
+ try {
+ // We need to peek at the stream and if the first three chars
+ // are a UTF-8 or UTF-16 encoded BOM (byte order mark) we will
+ // discard them.
+ int c1 = ((int) raw[0]) & 0xff;
+ int c2 = ((int) raw[1]) & 0xff;
+ int c3 = ((int) raw[2]) & 0xff;
+ int count = 0;
+ if (c1 == 0xFF & c2 == 0xFE) {
+ // UTF16 Big Endian BOM
+ // discard the first two chars
+ // pbis.unread(c3);
+ // return "UTF-16BE";
+ return 2;
+ } else if (c1 == 0xFE & c2 == 0xFF) {
+ // UTF16 Little Endian BOM
+ // discard the first two chars
+ // pbis.unread(c3);
+ // return "UTF-16LE";
+ return 2;
+ } else if (c1 == 0xEF && c2 == 0xBB && c3 == 0xBF) {
+ // // UTF-8 BOM
+ // // discard all three chars
+ // return "UTF-8";
+ return 3;
+ } else {
+ // Otherwise put back the chars we just read and proceed
+ // pbis.unread(c3);
+ // pbis.unread(c2);
+ // pbis.unread(c1);
+ // return null;
+ return 0;
+ }
+ } catch (Exception e) {
return 0;
}
}
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins