r176237 - Fix global overflow in types::lookupTypeForTypeSpecifier.

Evgeniy Stepanov eugeni.stepanov at gmail.com
Wed Feb 27 23:53:32 PST 2013


Author: eugenis
Date: Thu Feb 28 01:53:32 2013
New Revision: 176237

URL: http://llvm.org/viewvc/llvm-project?rev=176237&view=rev
Log:
Fix global overflow in types::lookupTypeForTypeSpecifier.

memcpy() is allowed to read entire contents of both memory areas.

Found with AddressSanitizer.

Modified:
    cfe/trunk/lib/Driver/Types.cpp

Modified: cfe/trunk/lib/Driver/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Types.cpp?rev=176237&r1=176236&r2=176237&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Types.cpp (original)
+++ cfe/trunk/lib/Driver/Types.cpp Thu Feb 28 01:53:32 2013
@@ -168,12 +168,10 @@ types::ID types::lookupTypeForExtension(
 }
 
 types::ID types::lookupTypeForTypeSpecifier(const char *Name) {
-  unsigned N = strlen(Name);
-
   for (unsigned i=0; i<numTypes; ++i) {
     types::ID Id = (types::ID) (i + 1);
     if (canTypeBeUserSpecified(Id) &&
-        memcmp(Name, getInfo(Id).Name, N + 1) == 0)
+        strcmp(Name, getInfo(Id).Name) == 0)
       return Id;
   }
 





More information about the cfe-commits mailing list