[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen

Csaba Dabis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 30 08:19:20 PDT 2018


Charusso updated this revision to Diff 149116.
Charusso added a comment.

@xbolva00 idea implemented, doubled the checker's power. Now if the given argument is a DeclRefExpr this should handle it as it would be inlined as a simple CallExpr.

Results:
I have found 37 `memcpy()` and 2 `memchr()` errors in: curl, FFmpeg, git, memcached, OpenSSL, PostGreSQL, Redis, twin.

Example of this new DRE case:
F6291767: postgresql-src-common-md5-c.html <https://reviews.llvm.org/F6291767>

Found `memchr()` errors:
F6291768: git-vcs-svn-fast_export-c.html <https://reviews.llvm.org/F6291768>
F6291769: twin-clients-dialog-c.html <https://reviews.llvm.org/F6291769>

All findings: F6291784: memcpy_and_memchr_errors.rar <https://reviews.llvm.org/F6291784>


https://reviews.llvm.org/D45050

Files:
  clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tidy/bugprone/CMakeLists.txt
  clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
  clang-tidy/bugprone/NotNullTerminatedResultCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/bugprone-not-null-terminated-result-in-initialization.c
  test/clang-tidy/bugprone-not-null-terminated-result-strlen-before-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-strlen-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen-before-safe.c
  test/clang-tidy/bugprone-not-null-terminated-result-wcslen-safe.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45050.149116.patch
Type: text/x-patch
Size: 56061 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180530/f48b3e84/attachment-0001.bin>


More information about the cfe-commits mailing list