Skip to content

Conversation

@p-mongo
Copy link
Contributor

@p-mongo p-mongo commented Oct 25, 2018

  • Explicitly reserve a byte for null terminator in strings
  • Only close the connection being worked on with sasl_dispose rather than all of them

- Explicitly reserve a byte for null terminator in strings
- Only close the connection being worked on with sasl_dispose rather than all of them
@p-mongo p-mongo requested a review from saghm December 18, 2018 20:33
/* from now on context owns conn */
/* since mongo_sasl_conn_free cleans up conn, we should NOT call */
/* sasl_dispose any more in this function. */
RB_GC_GUARD(context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be moved to below line 120? From what I can tell in the docs, RB_GC_GUARD) only guards the context up to the point where the macro is invoked, and so I think we want this invocation to be below the last usage of context.

result = sasl_encode64(raw_payload, raw_payload_len, encoded_payload, sizeof(encoded_payload), &encoded_payload_len);
/* I can't tell if the buffer size expected by sasl_encode64 includes */
/* the null terminator, thus be defensive and exclude it */
result = sasl_encode64(raw_payload, raw_payload_len, encoded_payload, sizeof(encoded_payload)-1, &encoded_payload_len);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to me like it's documented as null-terminated: https://docs.oracle.com/cd/E86824_01/html/E54774/sasl-encode64-3sasl.html

@p-mongo
Copy link
Contributor Author

p-mongo commented Dec 20, 2018

Made the requested changes.

@p-mongo p-mongo merged commit 0aaf0d0 into mongodb:master Jan 2, 2019
@p-mongo p-mongo deleted the native-ext branch January 2, 2019 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants