]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
fix operator>=(bufferlist& l, bufferlist& r)
authorLoic Dachary <loic@dachary.org>
Sat, 16 Feb 2013 09:11:15 +0000 (10:11 +0100)
committerSage Weil <sage@inktank.com>
Sat, 16 Feb 2013 22:51:40 +0000 (14:51 -0800)
commitc4573b745c3ffd5b67d9e210569b6318f6591d26
tree0af8fefe4d02ded7f3c6b6fc2880a73ba1855afb
parent37ef3f4b72371f9cc09748877d7e58bd0885e12f
fix operator>=(bufferlist& l, bufferlist& r)

  bufferlist a;
  a.append("A");
  bufferlist ab;
  ab.append("AB");

a >= ab failed, throwing an instance of 'ceph::buffer::end_of_buffer'
because it tried to access a[1]. All comparison operators should be
tested using a lexicographic sort like strcmp or memcmp (-1, 0, 1).
In the meantime, the missing test is added:

  if (l.length() == p && r.length() > p) return false;

A set of unit tests demonstrating the problem and covering all comparison
operators are added to show that the proposed fix works as expected.

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

Signed-off-by: Loic Dachary <loic@dachary.org>
src/include/buffer.h
src/test/bufferlist.cc