a checker for dangling string pointers in c
play

A checker for dangling string pointers in C++ in the Clang Static - PowerPoint PPT Presentation

A checker for dangling string pointers in C++ in the Clang Static Analyzer Rka Kovcs Mentors: Artem Dergachev Etvs Lornd University, Budapest, Hungary Gbor Horvth rekanikolett@gmail.com Real-world example return


  1. A checker for dangling string pointers in C++ in the Clang Static Analyzer Réka Kovács Mentors: Artem Dergachev Eötvös Loránd University, Budapest, Hungary Gábor Horváth rekanikolett@gmail.com

  2. Real-world example return std::to_string(size).c_str();

  3. Real-world example return std::to_string(size).c_str(); std::to_string() creates a temporary object the caller will receive a pointer to an already deallocated character buffer

  4. Real-world example * return std::to_string(size).c_str(); std::to_string() creates a temporary object the caller will receive a pointer to an already deallocated character buffer * found code like this in popular open-source projects

  5. cplusplus.InnerPointer Raw pointer to buffer obtained from string c_str(), data() Operation that re/deallocates the buffer dtor, =, +=, assign(), clear(), erase(), insert(), ... Use of the raw pointer ‘Inner pointer of container used after re/deallocation’

  6. cplusplus.InnerPointer Evaluated on a couple of open-source projects (+ dependencies): Bitcoin, Ceph, Harfbuzz, ICU, LibreOffice, LLVM, qBittorrent Found 3 true positives in Ceph, GPGME and Facebook’s RocksDB Reported & fixed within a day Found 0 false positives in these projects! Please try it out and give feedback!

  7. Future plans other STL / non-STL containers std::string_view

  8. How to use Analyze a project: Analyze one file: $ scan-build $ clang --analyze a.cpp Enabled by default Enabled by default

  9. Thanks! Final report: rnkovacs.github.io/gsoc2018 Réka Kovács / rekanikolett@gmail.com

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend