[llvm-bugs] [Bug 39792] New: False positive on strcpy targeting struct member

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Nov 26 10:22:32 PST 2018


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: dcoughlin at apple.com
          Reporter: pasa at strusoft.hu
                CC: dcoughlin at apple.com, llvm-bugs at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181126/8833c6f1/attachment.html>


More information about the llvm-bugs mailing list