]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/ConfUtils.cc: fix potential integer overflow
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Mon, 22 Feb 2016 16:23:12 +0000 (17:23 +0100)
committerSage Weil <sage@redhat.com>
Wed, 9 Nov 2016 19:44:57 +0000 (14:44 -0500)
Fix for:

CID 1128394 (#1 of 1): Integer overflowed argument (INTEGER_OVERFLOW)
 overflow: Add operation overflows on operands line_len and 1UL.
 overflow_assign: Assigning overflowed or truncated value (or a value
  computed from an overflowed or a truncated value) to rem.
 overflow_sink: Overflowed or truncated value (or a value computed from an
  overflowed or truncated value) rem used as critical argument to function.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/common/ConfUtils.cc

index 1ae5df54088955a7b4bb604d698905f6d17d1bc9..84ff626c37b112beb821dd9d83ad1ccd228cd64f 100644 (file)
@@ -297,6 +297,8 @@ load_from_buffer(const char *buf, size_t sz, std::deque<std::string> *errors,
   size_t rem = sz;
   while (1) {
     b += line_len + 1;
+    if ((line_len + 1) > rem)
+      break;
     rem -= line_len + 1;
     if (rem == 0)
       break;