Uploaded image for project: 'Libmongocrypt'
  1. Libmongocrypt
  2. MONGOCRYPT-242

libmongocrypt aborts when mongocrypt_ctx_decrypt_init is called with empty bson string

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None

      It appears that if mongocrypt_ctx_decrypt_init is called with an empty string as the bson buffer, the result is a BSON_ASSERT failure. In Ruby driver test suite this produces:

      (byebug) mongocrypt_ctx_decrypt_init(context.ctx_p, data_p)
      /data/mci/dd0591b7a0680c7f9aceb9cc30394457/libmongocrypt/src/mongocrypt-buffer.c:38 _make_owned(): precondition failed: buf->data
      

      I also wrote a C program at https://github.com/p-mongo/tests/blob/master/lmc-empty-bson/test-empty-bson.c which produces:

      speed% ./test-empty-bson 
      /data/mci/b36facda8d87bede21e55b88e924c257/libmongocrypt/src/mongocrypt-buffer.c:38 _make_owned(): precondition failed: buf->data
      zsh: abort      ./test-empty-bson
      
      
      
      

      libmongocrypt should handle empty bson string in a more graceful way, such as by returning an ordinary error to the caller in this case.

            Assignee:
            Unassigned Unassigned
            Reporter:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: