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

clang now issuing depreciation warnings on use of sprintf #364

Open
mclow opened this issue Nov 30, 2022 · 0 comments
Open

clang now issuing depreciation warnings on use of sprintf #364

mclow opened this issue Nov 30, 2022 · 0 comments

Comments

@mclow
Copy link
Contributor

mclow commented Nov 30, 2022

In file included from ./boost/test/output/compiler_log_formatter.hpp:19:
./boost/test/utils/setcolor.hpp:92:31: warning: '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. [-Wdeprecated-declarations]
        m_command_size = std::sprintf( m_control_command, "%c[%c;3%c;4%cm",
                              ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here
__deprecated_msg("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.")
^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
                                                      ^

The good news is that the change is really easy

- m_command_size = std::sprintf(  m_control_command,                            "%c[%c;3%c;4%cm",
+ m_command_size = std::snprintf( m_control_command, sizeof(m_control_command), "%c[%c;3%c;4%cm",

since m_control_command is a statically-sized array of char.

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

No branches or pull requests

1 participant