]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
fix null character in object name triggering segfault 175/head
authorLoic Dachary <loic@dachary.org>
Sat, 30 Mar 2013 10:26:12 +0000 (11:26 +0100)
committerLoic Dachary <loic@dachary.org>
Sat, 30 Mar 2013 13:28:34 +0000 (14:28 +0100)
commitc344ff170d278be6fc279c1275e8f17b14c72183
treea0a0bb4f0c279fcfd423acd04aadd32d92dad2be
parent2b8eb31b854cbae86dbddee73396d85601001b91
fix null character in object name triggering segfault

Parsing \n in  lfn_parse_object_name is implemented with

  out->append('\0');

which segfaults when using libstdc++ and g++ version 4.6.3 on Debian
GNU/Linux. It is replaced with

  (*out) += '\0';

to avoid the bugous implicit conversion. There is no append(charT)
method in C++98 or C++11, which means it relies on an implicit
conversion that is bugous. It would be better to rely on the
basic_string& operator+=(charT c); method as defined in ISO 14882-1998
(page 385) thru ISO 14882-2012 (page 640)

A set of tests is added to generate and parse object names. They need
access to the private function lfn_parse_object_name because there is
no convenient protected method to exercise it. The tests contain a
LFNIndex derived class, TestWrapLFNIndex which is made a friend of
LFNIndex to gain access to the private methods.

http://tracker.ceph.com/issues/4594 refs #4594

Signed-off-by: Loic Dachary <loic@dachary.org>
src/os/LFNIndex.cc
src/os/LFNIndex.h
src/test/os/TestLFNIndex.cc