r218367 - Fix the argument index error of __builtin___memccpy_chk
Steven Wu
stevenwu at apple.com
Tue Sep 23 21:37:33 PDT 2014
Author: steven_wu
Date: Tue Sep 23 23:37:33 2014
New Revision: 218367
URL: http://llvm.org/viewvc/llvm-project?rev=218367&view=rev
Log:
Fix the argument index error of __builtin___memccpy_chk
memccpy_check should have source and dest size at arg 3 and 4
rdar://18431336
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/builtin-object-size.c
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=218367&r1=218366&r2=218367&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Tue Sep 23 23:37:33 2014
@@ -365,7 +365,6 @@ Sema::CheckBuiltinFunctionCall(FunctionD
// check secure string manipulation functions where overflows
// are detectable at compile time
case Builtin::BI__builtin___memcpy_chk:
- case Builtin::BI__builtin___memccpy_chk:
case Builtin::BI__builtin___memmove_chk:
case Builtin::BI__builtin___memset_chk:
case Builtin::BI__builtin___strlcat_chk:
@@ -375,6 +374,9 @@ Sema::CheckBuiltinFunctionCall(FunctionD
case Builtin::BI__builtin___stpncpy_chk:
SemaBuiltinMemChkCall(*this, FDecl, TheCall, 2, 3);
break;
+ case Builtin::BI__builtin___memccpy_chk:
+ SemaBuiltinMemChkCall(*this, FDecl, TheCall, 3, 4);
+ break;
case Builtin::BI__builtin___snprintf_chk:
case Builtin::BI__builtin___vsnprintf_chk:
SemaBuiltinMemChkCall(*this, FDecl, TheCall, 1, 3);
Modified: cfe/trunk/test/Sema/builtin-object-size.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtin-object-size.c?rev=218367&r1=218366&r2=218367&view=diff
==============================================================================
--- cfe/trunk/test/Sema/builtin-object-size.c (original)
+++ cfe/trunk/test/Sema/builtin-object-size.c Tue Sep 23 23:37:33 2014
@@ -43,3 +43,12 @@ void f5(void)
memcpy((char *)NULL + 0x10000, buf, 0x10);
memcpy1((char *)NULL + 0x10000, buf, 0x10); // expected-error {{argument should be a value from 0 to 3}}
}
+
+// rdar://18431336
+void f6(void)
+{
+ char b[5];
+ char buf[10];
+ __builtin___memccpy_chk (buf, b, '\0', sizeof(b), __builtin_object_size (buf, 0));
+ __builtin___memccpy_chk (b, buf, '\0', sizeof(buf), __builtin_object_size (b, 0)); // expected-warning {{'__builtin___memccpy_chk' will always overflow destination buffer}}
+}
More information about the cfe-commits
mailing list