]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
librados: simplify/fix rados_pool_list bounds checks
authorSage Weil <sage@inktank.com>
Tue, 3 Jun 2014 18:45:20 +0000 (11:45 -0700)
committerSage Weil <sage@inktank.com>
Wed, 25 Jun 2014 21:30:08 +0000 (14:30 -0700)
commit6aa7f7ee4e082819decc48da1f0eaffc4e616302
tree395f84b11a68cf2dc42e9f412e624500f0825fd3
parent2ba03e08f1bce0a8af87014583d635eb5c0aa376
librados: simplify/fix rados_pool_list bounds checks

We were not breaking out of the loop when we filled up the buffer unless
we happened to do so on a pool name boundary.  This means that len would
roll over (it was unsigned).  In my case, I was not able to reproduce
anything particularly bad since (I think) the strncpy was interpreting the
large unsigned value as signed, but in any case this fixes it, simplifies
the arithmetic, and adds a simple test.

- use a single 'rl' value for the amount of buffer space we want to
  consume
- use this to check that there is room and also as the strncat length
- rely on the initial memset to ensure that the trailing 0 is in place.

Fixes: #8447
Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit 3ec32a6bb11d92e36a0e6381b40ce2fd1fbb016a)
src/librados/librados.cc
src/test/librados/pool.cc