Skip to content

GODRIVER-3770 Fix buffer handling in GSSAPI error description and username functions#2291

Merged
prestonvasquez merged 2 commits intomongodb:release/1.17from
prestonvasquez:bug/godriver3770-gssapi-buffer-update
Jan 20, 2026
Merged

GODRIVER-3770 Fix buffer handling in GSSAPI error description and username functions#2291
prestonvasquez merged 2 commits intomongodb:release/1.17from
prestonvasquez:bug/godriver3770-gssapi-buffer-update

Conversation

@prestonvasquez
Copy link
Member

@prestonvasquez prestonvasquez commented Jan 20, 2026

Fix buffer handling in gssapi_error_desc and gssapi_client_username to correctly copy buffer contents and null-terminate strings.

Verified with AddressSanitizer that buffer operations are correct.

@prestonvasquez prestonvasquez requested a review from a team as a code owner January 20, 2026 16:31
@github-actions github-actions bot added the review-priority-normal Medium Priority PR for Review: within 1 business day label Jan 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes buffer handling bugs in GSSAPI authentication code where memcpy was copying one byte beyond the allocated buffer. The changes ensure proper buffer copying and explicit null-termination of strings.

Changes:

  • Fixed buffer overflow in gssapi_error_desc by copying only the actual buffer length and adding explicit null-termination
  • Fixed identical buffer overflow in gssapi_client_username with the same approach
  • Added AddressSanitizer flags to the enterprise auth test to detect memory errors in GSSAPI C code

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
x/mongo/driver/auth/internal/gssapi/gss_wrapper.c Fixed buffer overflow bugs in error description and username functions by correcting memcpy length and adding explicit null-termination
README.md Added deprecation notice for this version of the Go driver
Makefile Added AddressSanitizer flags to enterprise auth test for memory error detection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@prestonvasquez prestonvasquez changed the base branch from master to release/1.17 January 20, 2026 16:31
@prestonvasquez prestonvasquez added review-priority-urgent High Priority PR for Review: review immediately! bug and removed review-priority-normal Medium Priority PR for Review: within 1 business day labels Jan 20, 2026
RafaelCenzano
RafaelCenzano previously approved these changes Jan 20, 2026
@mongodb-drivers-pr-bot
Copy link
Contributor

API Change Report

No changes found!

Copy link
Contributor

Choose a reason for hiding this comment

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

[Optional] I wonder if calloc is preferable to malloc since 0 padding is not necessary anymore.

@github-actions github-actions bot added the review-priority-normal Medium Priority PR for Review: within 1 business day label Jan 20, 2026
Copy link
Contributor

@qingyang-hu qingyang-hu left a comment

Choose a reason for hiding this comment

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

Thank you!

@prestonvasquez prestonvasquez merged commit 6798963 into mongodb:release/1.17 Jan 20, 2026
34 of 36 checks passed
@prestonvasquez prestonvasquez deleted the bug/godriver3770-gssapi-buffer-update branch January 20, 2026 22:43
prestonvasquez added a commit to prestonvasquez/mongo-go-driver that referenced this pull request Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug review-priority-normal Medium Priority PR for Review: within 1 business day review-priority-urgent High Priority PR for Review: review immediately!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants