From: David Reiss Date: Sun, 2 Mar 2008 00:20:47 +0000 (+0000) Subject: Fix potential out of bounds read issue with getTypeIDForTypeName(). X-Git-Tag: 0.2.0~936 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=2c9824c5bdd3d9aefa0c1edb4538c996e4d513dd;p=common%2Fthrift.git Fix potential out of bounds read issue with getTypeIDForTypeName(). Make sure type name is at least 2 characters long. git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665536 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/cpp/src/protocol/TJSONProtocol.cpp b/lib/cpp/src/protocol/TJSONProtocol.cpp index 39eb1290..d2d56c18 100644 --- a/lib/cpp/src/protocol/TJSONProtocol.cpp +++ b/lib/cpp/src/protocol/TJSONProtocol.cpp @@ -81,7 +81,7 @@ static const std::string &getTypeNameForTypeID(TType typeID) { static TType getTypeIDForTypeName(const std::string &name) { TType result = T_STOP; // Sentinel value - if (name.length() > 0) { + if (name.length() > 1) { switch (name[0]) { case 'd': result = T_DOUBLE;