Uploaded image for project: 'Couchbase Server'
  1. Couchbase Server
  2. MB-50521

Dereference of null pointer in spatial_modify make_nodelist

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 7.0.0, 7.0.2, 7.0.1
    • 7.1.0
    • storage-engine, view-engine
    • None
    • Untriaged
    • 1
    • Unknown

    Description

      Flagged by clang-scan the following code sets r to null, not what r points to.

      static nodelist *make_nodelist(arena* a, size_t bufsize)
      {
          nodelist *r = (nodelist *) arena_alloc(a, sizeof(nodelist) + bufsize);
          if (r == nullptr) {
              return nullptr;
          }
          r = {};  <--- r is now null
          r->data.size = bufsize; <--- deref null
          r->data.buf = ((char *) r) + (sizeof(nodelist));
          return r;
      }
      

      Code should be

      *r = {};
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            jwalker Jim Walker added a comment -

            Unclear how clang didn't spot earlier, maybe a newer clang now running?

            jwalker Jim Walker added a comment - Unclear how clang didn't spot earlier, maybe a newer clang now running?
            jwalker Jim Walker added a comment -

            Note: this code is in couchstore, but forms part of the view-engine, not KV-engine code.

            jwalker Jim Walker added a comment - Note: this code is in couchstore, but forms part of the view-engine, not KV-engine code.

            Build couchbase-server-7.1.0-2122 contains couchstore commit b21d5b1 with commit message:
            MB-50521: Fix deference of nullptr in spatial_modify.cc make_nodelist

            build-team Couchbase Build Team added a comment - Build couchbase-server-7.1.0-2122 contains couchstore commit b21d5b1 with commit message: MB-50521 : Fix deference of nullptr in spatial_modify.cc make_nodelist
            jwalker Jim Walker added a comment -

            fix in 7.1 neo

            jwalker Jim Walker added a comment - fix in 7.1 neo

            People

              jwalker Jim Walker
              jwalker Jim Walker
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty