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

2018-06-09 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 150644. Charusso added a comment. Clang format. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cpp clang-tidy/bugprone/CMakeLists.txt clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp clang-tidy/bugprone/NotNullTer

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

2018-06-09 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment. @lebedev.ri there is all the false positive results from the last publicated result-dump: F6334659: curl-lib-curl_path-c.html second result: F6334660: ffmpeg-libavformat-sdp.c.html all result: F633

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

2018-06-09 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 150643. Charusso marked 4 inline comments as done. Charusso added a comment. `memchr()` revision: it is problematic if the second argument is `'\0'`, there is no other case. Added a new type of matcher, to match function calls. More static functions and tes

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

2018-06-02 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment. In https://reviews.llvm.org/D45050#1116446, @lebedev.ri wrote: > I would like to see more negative tests. > What does it do if the len/size is a constant? > Variable that wasn't just assigned with `strlen()` return? Thanks for the comment! What do you mean by negativ

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

2018-05-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment. In https://reviews.llvm.org/D45050#1116361, @xbolva00 wrote: > memcpy(crypt_buf, passwd, passwd_len); <--- warning > memcpy(crypt_buf + passwd_len, salt, salt_len); > > This is a false warning since it appends strings using memcpy. But no idea > what to do and if it is

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

2018-05-30 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 149129. Charusso added a comment. Clang format. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cpp clang-tidy/bugprone/CMakeLists.txt clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp clang-tidy/bugprone/NotNullTer

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

2018-05-30 Thread Csaba Dabis via Phabricator via cfe-commits
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()` er

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

2018-04-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment. In https://reviews.llvm.org/D45050#1071897, @xbolva00 wrote: > Shouldn't it catch in curl also this code? > > urllen = strlen(url_clone); > > > > memcpy(newest, url_clone, urllen); > > Edit: if possible, report these bugs to project developers :) Thanks for your

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

2018-04-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 143825. Charusso marked an inline comment as done. Charusso added a comment. Defined an option to switch off the `_s` suffixed functions usage. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cpp clang-tidy/bugprone/CMakeL

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

2018-04-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 143698. Charusso marked an inline comment as done. Charusso added a comment. Changed CXX11 to C11 and made a little refactor. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cpp clang-tidy/bugprone/CMakeLists.txt clang-t

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

2018-04-24 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked an inline comment as done. Charusso added inline comments. Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:226 +DiagnosticBuilder &Diag) { + if (getLangOpts().CPlusPlus11) { +StringRef NewFuncName = (Name[0] != 'w') ? "strncpy_s" : "wcsnc

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

2018-04-19 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment. I tried my checker on 10 famous open source project, this is the outcome: F5977628: curl_lib_transfer_c.html F5977629: ffmpeg_libavformat_sdp_c.html F5977631: openssl_apps_ca_c.html

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

2018-04-18 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 143025. Charusso marked an inline comment as done. Charusso added a comment. Everything fixed. Thanks you @lebedev.ri for the early comments, I forgot to submit my comment. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cp

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

2018-04-18 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked 14 inline comments as done. Charusso added inline comments. Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:226 +DiagnosticBuilder &Diag) { + if (getLangOpts().CPlusPlus11) { +StringRef NewFuncName = (Name[0] != 'w') ? "strncpy_s" : "wcsn

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

2018-03-29 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 140337. Charusso marked 6 inline comments as done. Charusso added a comment. Truly fixed everything according to the comments. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cpp clang-tidy/bugprone/CMakeLists.txt clang-

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

2018-03-29 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 140330. Charusso marked 2 inline comments as done. Charusso added a comment. Fixed everything according to the comments. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cpp clang-tidy/bugprone/CMakeLists.txt clang-tidy/b

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

2018-03-29 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 140294. Charusso marked 5 inline comments as done. Charusso added a comment. Added the whole diff. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cpp clang-tidy/bugprone/CMakeLists.txt clang-tidy/bugprone/NotNullTermina

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

2018-03-29 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 140288. Charusso added a comment. Fixed the unseen diff issues, removed redundant parentheses, the class got a private part. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp clang-tidy/bugprone/NotNullTermina

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

2018-03-29 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision. Charusso added reviewers: alexfh, aaron.ballman, xazax.hun. Charusso added a project: clang-tools-extra. Herald added subscribers: cfe-commits, rnkovacs, mgorny. New checker called bugprone-not-null-terminated-result. This check can be used to find function calls w

<    2   3   4   5   6   7