[PATCH] D154838: [analyzer] Add check for null pointer passed to %p of printf family

Georgiy Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 10 05:58:00 PDT 2023


CuriousGeorgiy created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
CuriousGeorgiy requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add a new check to the UnixAPI portability checker: the result of passing a
null pointer to pointer conversion specifier of printf family of functions
is implementation defined — for instance, on Windows zeros are printed,
whilst on Linux '(nil)' is printed.

The check assumes that a null pointer is only passed to a pointer
conversion specifier, otherwise it would be undefined behaviour. By making
this assumption we do not have to check the format string and match data
arguments to conversion specifiers.

Closes #43453


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154838

Files:
  clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
  clang/test/Analysis/Inputs/expected-plists/unix-fns.c.plist
  clang/test/Analysis/unix-fns.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154838.538600.patch
Type: text/x-patch
Size: 117937 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230710/c4f7f7ff/attachment-0001.bin>


More information about the cfe-commits mailing list