strlcpy_strlcat_warning_removed
authorLLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Wed, 30 Nov 2022 14:31:52 +0000 (14:31 +0000)
committerGianfranco Costamagna <locutusofborg@debian.org>
Wed, 30 Nov 2022 14:31:52 +0000 (14:31 +0000)
Gbp-Pq: Name 23-strlcpy_strlcat_warning_removed.diff

clang/include/clang/Basic/Builtins.def
clang/lib/AST/Decl.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/test/Sema/builtins.c
clang/test/Sema/warn-strlcpycat-size.c [deleted file]

index f19807dbbb0bbec1b81972853a947cc3f090afb0..b7c97cb24410ed0b23598f71fc981de9583c8a4e 100644 (file)
@@ -624,8 +624,8 @@ BUILTIN(__builtin___memset_chk, "v*v*izz", "nF")
 BUILTIN(__builtin___stpcpy_chk, "c*c*cC*z", "nF")
 BUILTIN(__builtin___strcat_chk, "c*c*cC*z", "nF")
 BUILTIN(__builtin___strcpy_chk, "c*c*cC*z", "nF")
-BUILTIN(__builtin___strlcat_chk, "zc*cC*zz", "nF")
-BUILTIN(__builtin___strlcpy_chk, "zc*cC*zz", "nF")
+//BUILTIN(__builtin___strlcat_chk, "zc*cC*zz", "nF")
+//BUILTIN(__builtin___strlcpy_chk, "zc*cC*zz", "nF")
 BUILTIN(__builtin___strncat_chk, "c*c*cC*zz", "nF")
 BUILTIN(__builtin___strncpy_chk, "c*c*cC*zz", "nF")
 BUILTIN(__builtin___stpncpy_chk, "c*c*cC*zz", "nF")
@@ -1143,8 +1143,8 @@ LIBBUILTIN(getcontext, "iK*",     "fjT",   "setjmp.h", ALL_LANGUAGES)
 LIBBUILTIN(_longjmp, "vJi",       "frT",   "setjmp.h", ALL_GNU_LANGUAGES)
 LIBBUILTIN(siglongjmp, "vSJi",    "frT",   "setjmp.h", ALL_GNU_LANGUAGES)
 // non-standard but very common
-LIBBUILTIN(strlcpy, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
-LIBBUILTIN(strlcat, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
+//LIBBUILTIN(strlcpy, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
+//LIBBUILTIN(strlcat, "zc*cC*z",    "f",     "string.h", ALL_GNU_LANGUAGES)
 //   id objc_msgSend(id, SEL, ...)
 LIBBUILTIN(objc_msgSend, "GGH.",   "f",     "objc/message.h", OBJC_LANG)
 // long double objc_msgSend_fpret(id self, SEL op, ...)
index aaba4345587b2ee183994326c948f68034c7e90e..c2464733295d4307dd3ddc0868149ce4dc83ed25 100644 (file)
@@ -4141,13 +4141,13 @@ unsigned FunctionDecl::getMemoryFunctionKind() const {
   case Builtin::BImemmove:
     return Builtin::BImemmove;
 
-  case Builtin::BIstrlcpy:
-  case Builtin::BI__builtin___strlcpy_chk:
-    return Builtin::BIstrlcpy;
+//  case Builtin::BIstrlcpy:
+//  case Builtin::BI__builtin___strlcpy_chk:
+//    return Builtin::BIstrlcpy;
 
-  case Builtin::BIstrlcat:
-  case Builtin::BI__builtin___strlcat_chk:
-    return Builtin::BIstrlcat;
+//  case Builtin::BIstrlcat:
+//  case Builtin::BI__builtin___strlcat_chk:
+//    return Builtin::BIstrlcat;
 
   case Builtin::BI__builtin_memcmp:
   case Builtin::BImemcmp:
index dae51d0690e6d496e05ad02870b3482cd8f1bbf2..f8b7a44a047d7b011835a38e7d6da1c11d508f18 100644 (file)
@@ -1223,8 +1223,8 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
   case Builtin::BI__builtin___memcpy_chk:
   case Builtin::BI__builtin___memmove_chk:
   case Builtin::BI__builtin___memset_chk:
-  case Builtin::BI__builtin___strlcat_chk:
-  case Builtin::BI__builtin___strlcpy_chk:
+//  case Builtin::BI__builtin___strlcat_chk:
+//  case Builtin::BI__builtin___strlcpy_chk:
   case Builtin::BI__builtin___strncat_chk:
   case Builtin::BI__builtin___strncpy_chk:
   case Builtin::BI__builtin___stpncpy_chk:
@@ -5890,10 +5890,10 @@ bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
   switch (CMId) {
   case 0:
     return false;
-  case Builtin::BIstrlcpy: // fallthrough
+/*  case Builtin::BIstrlcpy: // fallthrough
   case Builtin::BIstrlcat:
     CheckStrlcpycatArguments(TheCall, FnInfo);
-    break;
+    break;*/
   case Builtin::BIstrncat:
     CheckStrncatArguments(TheCall, FnInfo);
     break;
index f0a114801dda5f29cd373e066e7cc7c440751b8f..7b543a0246ce528b06222c8b8e070745380ee297 100644 (file)
@@ -652,10 +652,10 @@ void GenericTaintChecker::initTaintRules(CheckerContext &C) const {
 
       {{CDF_MaybeBuiltin, {BI.getName(Builtin::BIstrncat)}},
        TR::Prop({{1, 2}}, {{0, ReturnValueIndex}})},
-      {{CDF_MaybeBuiltin, {BI.getName(Builtin::BIstrlcpy)}},
+/*      {{CDF_MaybeBuiltin, {BI.getName(Builtin::BIstrlcpy)}},
        TR::Prop({{1, 2}}, {{0}})},
       {{CDF_MaybeBuiltin, {BI.getName(Builtin::BIstrlcat)}},
-       TR::Prop({{1, 2}}, {{0}})},
+      TR::Prop({{1, 2}}, {{0}})},*/
       {{CDF_MaybeBuiltin, {"snprintf"}},
        TR::Prop({{1}, 3}, {{0, ReturnValueIndex}})},
       {{CDF_MaybeBuiltin, {"sprintf"}},
index b3ef004bec0f4b53e8cd6ddc2ce62af4a2ccf362..74406aa89131615a25f9619d762a82eadb3a51cc 100644 (file)
@@ -197,12 +197,10 @@ void test18(void) {
   void *ptr;
 
   ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src), sizeof(dst));
-  result = __builtin___strlcpy_chk(dst, src, sizeof(dst), sizeof(dst));
   result = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst));
 
   ptr = __builtin___memccpy_chk(dst, src, '\037', sizeof(src));      // expected-error {{too few arguments to function call}}
   ptr = __builtin___strlcpy_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-error {{incompatible integer to pointer conversion}}
-  ptr = __builtin___strlcat_chk(dst, src, sizeof(dst), sizeof(dst)); // expected-error {{incompatible integer to pointer conversion}}
 }
 
 void no_ms_builtins(void) {
@@ -217,6 +215,7 @@ void unavailable(void) {
 }
 
 // rdar://18259539
+/*
 size_t strlcpy(char * restrict dst, const char * restrict src, size_t size);
 size_t strlcat(char * restrict dst, const char * restrict src, size_t size);
 
@@ -238,6 +237,7 @@ void Test19(void)
                                                                                    // expected-note {{change size argument to be the size of the destination}} \
                                                                                   // expected-warning {{'strlcat' will always overflow; destination buffer has size 20, but size argument is 40}}
 }
+*/
 
 // rdar://11076881
 char * Test20(char *p, const char *in, unsigned n)
diff --git a/clang/test/Sema/warn-strlcpycat-size.c b/clang/test/Sema/warn-strlcpycat-size.c
deleted file mode 100644 (file)
index c471665..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-// RUN: %clang_cc1 -Wstrlcpy-strlcat-size -verify -fsyntax-only %s
-
-typedef __SIZE_TYPE__ size_t;
-size_t strlcpy (char * restrict dst, const char * restrict src, size_t size);
-size_t strlcat (char * restrict dst, const char * restrict src, size_t size);
-size_t strlen (const char *s);
-
-char s1[100];
-char s2[200];
-char * s3;
-
-struct {
-  char f1[100];
-  char f2[100][3];
-} s4, **s5;
-
-int x;
-
-void f(void)
-{
-  strlcpy(s1, s2, sizeof(s1)); // no warning
-  strlcpy(s1, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
-  strlcpy(s1, s3, strlen(s3)+1); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
-  strlcat(s2, s3, sizeof(s3)); // expected-warning {{size argument in 'strlcat' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
-  strlcpy(s4.f1, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
-  strlcpy((*s5)->f2[x], s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
-  strlcpy(s1+3, s2, sizeof(s2)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
-}
-
-// Don't issue FIXIT for flexible arrays.
-struct S {
-  int y; 
-  char x[];
-};
-
-void flexible_arrays(struct S *s) {
-  char str[] = "hi";
-  strlcpy(s->x, str, sizeof(str));  // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
-}
-
-// Don't issue FIXIT for destinations of size 1.
-void size_1(void) {
-  char z[1];
-  char str[] = "hi";
-
-  strlcpy(z, str, sizeof(str));  // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}}
-}
-
-// Support VLAs.
-void vlas(int size) {
-  char z[size];
-  char str[] = "hi";
-
-  strlcpy(z, str, sizeof(str)); // expected-warning {{size argument in 'strlcpy' call appears to be size of the source; expected the size of the destination}} expected-note {{change size argument to be the size of the destination}}
-}