Neuter stack protectors by only checking character arrays. This is what GCC
authorBill Wendling <isanbard@gmail.com>
Fri, 23 Oct 2009 00:01:05 +0000 (00:01 +0000)
committerBill Wendling <isanbard@gmail.com>
Fri, 23 Oct 2009 00:01:05 +0000 (00:01 +0000)
does.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84916 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/StackProtector.cpp

index 350bc6e1ade7db9e09e30da3c6353ff9e4e3970a..020496933338d5421e00fcbd40cb4fb6561db2e4 100644 (file)
@@ -111,11 +111,16 @@ bool StackProtector::RequiresStackProtector() const {
           // protectors.
           return true;
 
-        if (const ArrayType *AT = dyn_cast<ArrayType>(AI->getAllocatedType()))
+        if (const ArrayType *AT = dyn_cast<ArrayType>(AI->getAllocatedType())) {
+          // We apparently only care about character arrays.
+          if (AT->getElementType() != Type::getInt8Ty(AT->getContext()))
+            continue;
+
           // If an array has more than SSPBufferSize bytes of allocated space,
           // then we emit stack protectors.
           if (SSPBufferSize <= TD->getTypeAllocSize(AT))
             return true;
+        }
       }
   }