Skip to content

Buffer overflow in cursor create_name_map #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

juliuszsompolski
Copy link

Function create_name_map used a static buffer szName[300] for the column name in call to SQLDescribeColW. That function would truncate the column name to the size of the provided buffer, but return the actual length of the column name in the &cchName return parameter.
That cchName output was used to compute cbName parameter for the call to TextBufferToObject(enc, szName, cbName). When the actual column name was longer than the buffer, cbName was to big, and was causing a buffer overflow, resulting in crashes, invalid data, or errors.

Fix this by making szName a dynamic buffer. This buffer overflow is very similar to the one fixed in mkleehammer#881. I check through the rest of the code base, and I don't see more places with static buffers that could have a similar issue.

Upstream PR: mkleehammer#931

@juliuszsompolski juliuszsompolski merged commit 619101f into databricks:master Jul 15, 2021
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.

1 participant