[PATCH] D45177: CStringChecker, check strlcpy/strlcat

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 30 17:33:15 PDT 2018


NoQ added a comment.

Whoops - this isn't quite correct because there's one more difference between strlcpy/strlcat and the standard strcpy/strcat/strncpy/strncat: the return value. After this patch the new functions are modeled as if they return a pointer into the string, which is incorrect and in fact causes crashes.

One of the crashes is on the following code:

  int foo(char *d) {
    char e[1];
    return strlcpy(e, d, sizeof(e)) >= sizeof(e);
  }

...when analyzed as `clang -cc1 -w -analyze -analyzer-checker=core,unix repro.c`.

David, would you be willing to have a look at this problem?

Also I forgot to add the tests before committing. Sorry!


Repository:
  rC Clang

https://reviews.llvm.org/D45177





More information about the cfe-commits mailing list