]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
SubProcess: Avoid buffer corruption when calling err() 8054/head
authorErwan Velu <erwan@redhat.com>
Fri, 11 Mar 2016 15:27:34 +0000 (16:27 +0100)
committerErwan Velu <erwan@redhat.com>
Mon, 14 Mar 2016 09:46:51 +0000 (10:46 +0100)
commitaec9cd2390fec736ee5673adb30261b8d31a873c
treeb22012389b90aed8f479c22511d41b5791dec6a8
parent0d6d340087e1dc276794f81fc61219ce8881089a
SubProcess: Avoid buffer corruption when calling err()

Some code like crush/CrushTester.cc, uses err() to get the output status of a
spawned command.

As per reported in bug #15011, some tests were failing because of some utf8
decoding issues. The implied buffers were generated by the output of err()
function of SubProcess.

err() is returning the str().c_str() value of 'errstr' object which is not
living much longer that the function itself.

This patch returns a std::string to avoid the temporary allocation and fixes
the associated err() calls accordingly.

Since this commit, the make check is now passing everytime.

Fixes: #15011
Signed-off-by: Erwan Velu <erwan@redhat.com>
src/common/SubProcess.h
src/test/librbd/fsx.cc
src/test/test_subprocess.cc