[libc-commits] [PATCH] D143782: [libc] Prevent printf index mode crashes
Michael Jones via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Feb 10 14:58:36 PST 2023
michaelrj created this revision.
michaelrj added reviewers: sivachandra, lntue.
Herald added subscribers: libc-commits, ecnelises, tschuett, arphaman.
Herald added projects: libc-project, All.
michaelrj requested review of this revision.
The posix standard defines an alternate mode for printf where the
conversions also have an index that describes which argument to select.
Due to how variadic arguments work in C, to reach the nth argument all
n-1 previous arguments must be read with their correct types. If the
format string does not specify the types for a continuous set of
arguments, then the arguments after the discontinuity cannot be safely
read. This patch causes all conversions requesting an argument that
comes after a gap be treated as raw (i.e. the conversion string is
printed literally).
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143782
Files:
libc/src/stdio/printf_core/core_structs.h
libc/src/stdio/printf_core/parser.cpp
libc/src/stdio/printf_core/parser.h
libc/test/src/stdio/printf_core/parser_test.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143782.496609.patch
Type: text/x-patch
Size: 11067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230210/37a21c70/attachment.bin>
More information about the libc-commits
mailing list