]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commit
log/Log: fix buffer overflow
authorSage Weil <sage@redhat.com>
Sat, 4 Aug 2018 03:16:21 +0000 (22:16 -0500)
committerSage Weil <sage@redhat.com>
Mon, 6 Aug 2018 13:51:28 +0000 (08:51 -0500)
commit891d8b47544898195bf5516a26e42cabd76df4ce
tree90e35ca6fbcda4d4d145b14a3d5a0f611be6f865
parentda7602be502393634e6262b581145ce7211c5b40
log/Log: fix buffer overflow

If we have a long line that has to be dynamically allocated, we need to
adjust m_log_buf_pos accordingly afterward.  In particular,
_write_and_copy does this adjustment, which means the later += line_used
is not only unnecessary but very bad, since line_used is > MAX_LOG_BUF.

Simplify all of this by getting rid of _write_and_copy: if we are writing
a big chunk let's just send the whole thing to m_fd and not bother keeping
the tail of it around for later.

Fix _log_safe_write to write the passed buffer, not m_log_buf.

Replace the paranoid check with a simple assert.

Fixes: 65da5ba216cafb8a91893d0e7fc092209f0fb286
Fixes: https://github.com/ceph/ceph/pull/23422
Signed-off-by: Sage Weil <sage@redhat.com>
src/log/Log.cc
src/log/Log.h