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

Some API calls don't fail gracefully if called with NULL handle

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 4.5.0
    • .master
    • forestdb
    • None
    • Untriaged
    • Unknown
    • ForestDB: Oct 17 - Nov 4

    Description

      Most ForestDB public functions check the input handle for NULL and return an error, typically
      FDB_RESULT_INVALID_HANDLE, sometimes FDB_RESULT_INVALID_ARGS. But not all of them do.

      I haven't looked through the entire API, just the functions that I use, but these are the functions I've found that will crash if called with a null handle:
      fdb_rekey
      fdb_begin_transaction
      fdb_end_transaction
      fdb_compact (and related functions)
      fdb_set_log_callback
      fdb_rollback [checks for handle_ptr==NULL, but not *handle_ptr==NULL]
      fdb_set
      fdb_del
      fdb_get_byoffset
      fdb_get_metaonly_byseq (it does check for NULL, but on the line above it deferences the handle, oops)

      This is significant for code that wraps ForestDB for use in a garbage-collected environment. The GC object holding a FDB handle will probably have a close() method to close the handle, which will then set the handle to NULL. But since the object is still alive, it could potentially be called afterwards. If ForestDB is not safe when called with NULL handles, then this adapter layer has to be careful to check the handle for NULL before every ForestDB call.

      Attachments

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

        Activity

          People

            abhinav Abhi Dangeti
            jens Jens Alfke
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty