Skip to content
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

Deprecate 'sprintf' usage using MacOSX SDK 13 #5545

Merged
merged 2 commits into from
Dec 1, 2022

Conversation

darrenfu
Copy link
Contributor

(This change will be a dependency to fix a Velox build failure, see facebookincubator/velox#3370)

Using MacOS 13.0 sdk, you may notice the following build error:

error: 'sprintf' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Werror,-Wdeprecated-declarations]

The alternative safer function is snprintf.

Reference: https://stackoverflow.com/a/2169039

@darrenfu
Copy link
Contributor Author

@pedroerp - since you had experience to build duckdb code, would you help review this PR?

sprintf(target + 7, "%03d", (int)exchg);
sprintf(target + 11, "%04d", (int)number);
snprintf(target, PHONE_LEN, "%02d", (int)(10 + (ind % NATIONS_MAX)));
snprintf(target + 3, PHONE_LEN, "%03d", (int)acode);
Copy link
Member

Choose a reason for hiding this comment

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

if we snprintf to ptr + 3, isn't PHONE_LEN too much n by 3?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for pointing out!
I've amended a fix to set the correct buffer size with a few tests: https://onlinegdb.com/XL_2XQdz1

@darrenfu darrenfu requested a review from hannes November 30, 2022 06:38
@Mytherin Mytherin merged commit 80d644a into duckdb:master Dec 1, 2022
@Mytherin
Copy link
Collaborator

Mytherin commented Dec 1, 2022

Thanks!

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.

None yet

3 participants