Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
improved checkAutoType.
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jan 1, 2018
1 parent 6d56d0e commit 5501d48
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/com/alibaba/fastjson/parser/ParserConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,19 @@ public Class<?> checkAutoType(String typeName, Class<?> expectClass, int feature
return null;
}

if (typeName.length() >= 128) {
if (typeName.length() >= 128 || typeName.length() < 3) {
throw new JSONException("autoType is not support. " + typeName);
}

long hashCode = 0xcbf29ce484222325L;
final long BASIC = 0xcbf29ce484222325L;
final long PRIME = 0x100000001b3L;

final long h1 = (BASIC ^ typeName.charAt(0)) * PRIME;
if (h1 == 0xaf64164c86024f1aL) { // [
throw new JSONException("autoType is not support. " + typeName);
}

long hashCode = BASIC;
for (int i = 0; i < typeName.length(); ++i) {
char c = typeName.charAt(i);
hashCode ^= c;
Expand Down

0 comments on commit 5501d48

Please sign in to comment.