]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
<common> fix formatter buffer out-of-bounds
authorliubingrun <liubr1@chinatelecom.cn>
Thu, 24 Oct 2024 10:02:12 +0000 (06:02 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 16 Dec 2024 18:21:36 +0000 (13:21 -0500)
commitc88550c7b8fcfeabb79fa95c37c9d5d692de5ba2
tree614339c1535bfcb84e585016fcc5ef2301c52ca3
parenta1b54e03f5fc2ff00aee793b5fcc21e1125cc1be
<common> fix formatter buffer out-of-bounds

  The length of buf in Formatter is 1024. If the output was truncated due to size limit,
  then the return value is the number of characters (excluding the terminating null byte)
  which would have been written to the final string if enough space had been available.
  So XMLFormatter::dump_format_va will create a string_view that out of bounds of buf.

  use boost small_vector to allocate more buffer when content is too
  long to fit in the buffer pre-alloced

Signed-off-by: liubingrun <liubr1@chinatelecom.cn>
(cherry picked from commit 207003c512396b1381abbf1a4929186c21827060)
src/common/Formatter.cc
src/test/common/test_json_formatter.cc
src/test/common/test_tableformatter.cc
src/test/common/test_xmlformatter.cc