]> git.ipfire.org Git - thirdparty/glibc.git/commit
stdio: Remove memory leak from multibyte convertion [BZ#25691]
authorFlorian Weimer <fweimer@redhat.com>
Thu, 19 Mar 2020 21:32:28 +0000 (18:32 -0300)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 30 Aug 2022 09:03:56 +0000 (11:03 +0200)
commite68db8bf5af3f8ced6ccce132906d6899a6cb34a
tree6a0763ff789281c078d1656b75451173ded8903a
parentefe736ebe7782d41a70c08e6d77d7c7a48cba54a
stdio: Remove memory leak from multibyte convertion [BZ#25691]

This is an updated version of a previous patch [1] with the
following changes:

  - Use compiler overflow builtins on done_add_func function.
  - Define the scratch +utstring_converted_wide_string using
    CHAR_T.
  - Added a testcase and mention the bug report.

Both default and wide printf functions might leak memory when
manipulate multibyte characters conversion depending of the size
of the input (whether __libc_use_alloca trigger or not the fallback
heap allocation).

This patch fixes it by removing the extra memory allocation on
string formatting with conversion parts.

The testcase uses input argument size that trigger memory leaks
on unpatched code (using a scratch buffer the threashold to use
heap allocation is lower).

Checked on x86_64-linux-gnu and i686-linux-gnu.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
[1] https://sourceware.org/pipermail/libc-alpha/2017-June/082098.html

(cherry picked from commit 3cc4a8367c23582b7db14cf4e150e4068b7fd461)
NEWS
stdio-common/vfprintf-internal.c