https://bugs.llvm.org/show_bug.cgi?id=39792

            Bug ID: 39792
           Summary: False positive on strcpy targeting struct member
           Product: clang
           Version: 7.0
          Hardware: All
                OS: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P
         Component: Static Analyzer
          Assignee: dcough...@apple.com
          Reporter: p...@strusoft.hu
                CC: dcough...@apple.com, llvm-bugs@lists.llvm.org

The code below is correctly silent on the first strcpy but warns on the second.
It should be silenced whenever the target is large enough to contain the string
literal regardless where the target is located.


void f()
{
  char s1[100];
  strcpy(s1, "hello");

  struct S {char s1[100];};
  S s;
  strcpy(s.s1, "hello");
}

 warning: Call to function 'strcpy' is insecure as it does not provide bounding
of the memory buffer. Replace unbounded copy functions with analogous functions
that support length arguments such as 'strlcpy'. CWE-119
[clang-analyzer-security.insecureAPI.strcpy]
  strcpy(s.s1, "hello");
  ^

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to