]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/denc.h: throw exception if insufficient buffer during header decode
authorSamuel Just <sjust@redhat.com>
Mon, 4 May 2020 18:44:07 +0000 (11:44 -0700)
committerSamuel Just <sjust@redhat.com>
Thu, 7 May 2020 06:40:36 +0000 (23:40 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/include/denc.h

index a7dd3cca4ff2b8e37cab29fcb8713e68d79f0b99..6cc53277b94502596b1eb8281937d3ad47cae487 100644 (file)
@@ -38,7 +38,6 @@
 #include <boost/intrusive/set.hpp>
 #include <boost/optional.hpp>
 
-#include "include/ceph_assert.h"       // boost clobbers this
 #include "include/intarith.h"
 #include "include/int_types.h"
 #include "include/scope_guard.h"
@@ -1736,7 +1735,9 @@ inline std::enable_if_t<traits::supported && !traits::featured> decode_nohead(
                           uint32_t *struct_len) {                      \
     const char *pos = p.get_pos();                                     \
     char *end = *start_pos + *struct_len;                              \
-    ceph_assert(pos <= end);                                                   \
+    if (pos > end) {                                                   \
+      throw ::ceph::buffer::malformed_input(__PRETTY_FUNCTION__);      \
+    }                                                                  \
     if (pos < end) {                                                   \
       p += end - pos;                                                  \
     }                                                                  \