mirror of
https://github.com/boostorg/asio.git
synced 2026-02-26 14:52:09 +00:00
Use snprintf rather than sprintf on latest Xcode.
This commit is contained in:
@@ -2193,4 +2193,15 @@
|
||||
# endif // !defined(BOOST_ASIO_DISABLE_STD_TO_ADDRESS)
|
||||
#endif // !defined(BOOST_ASIO_HAS_STD_TO_ADDRESS)
|
||||
|
||||
// Standard library support for snprintf.
|
||||
#if !defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
# if !defined(BOOST_ASIO_DISABLE_SNPRINTF)
|
||||
# if defined(__apple_build_version__)
|
||||
# if (__clang_major__ >= 14)
|
||||
# define BOOST_ASIO_HAS_SNPRINTF 1
|
||||
# endif // (__clang_major__ >= 14)
|
||||
# endif // defined(__apple_build_version__)
|
||||
# endif // !defined(BOOST_ASIO_DISABLE_SNPRINTF)
|
||||
#endif // !defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
|
||||
#endif // BOOST_ASIO_DETAIL_CONFIG_HPP
|
||||
|
||||
@@ -366,7 +366,9 @@ void handler_tracking::write_line(const char* format, ...)
|
||||
va_start(args, format);
|
||||
|
||||
char line[256] = "";
|
||||
#if defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
#if defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
int length = vsnprintf(line, sizeof(line), format, args);
|
||||
#elif defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
int length = vsprintf_s(line, sizeof(line), format, args);
|
||||
#else // defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
int length = vsprintf(line, format, args);
|
||||
|
||||
@@ -2520,7 +2520,11 @@ const char* inet_ntop(int af, const void* src, char* dest, size_t length,
|
||||
&& ((ipv6_address->s6_addr[1] & 0x0f) == 0x02));
|
||||
if ((!is_link_local && !is_multicast_link_local)
|
||||
|| if_indextoname(static_cast<unsigned>(scope_id), if_name + 1) == 0)
|
||||
#if defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
snprintf(if_name + 1, sizeof(if_name) - 1, "%lu", scope_id);
|
||||
#else // defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
sprintf(if_name + 1, "%lu", scope_id);
|
||||
#endif // defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
strcat(dest, if_name);
|
||||
}
|
||||
return result;
|
||||
@@ -3628,7 +3632,9 @@ inline boost::system::error_code getnameinfo_emulation(
|
||||
{
|
||||
return ec = boost::asio::error::no_buffer_space;
|
||||
}
|
||||
#if defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
#if defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
snprintf(serv, servlen, "%u", ntohs(port));
|
||||
#elif defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
sprintf_s(serv, servlen, "%u", ntohs(port));
|
||||
#else // defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
sprintf(serv, "%u", ntohs(port));
|
||||
@@ -3651,7 +3657,9 @@ inline boost::system::error_code getnameinfo_emulation(
|
||||
{
|
||||
return ec = boost::asio::error::no_buffer_space;
|
||||
}
|
||||
#if defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
#if defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
snprintf(serv, servlen, "%u", ntohs(port));
|
||||
#elif defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
sprintf_s(serv, servlen, "%u", ntohs(port));
|
||||
#else // defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
sprintf(serv, "%u", ntohs(port));
|
||||
|
||||
@@ -130,7 +130,9 @@ std::string network_v4::to_string(boost::system::error_code& ec) const
|
||||
using namespace std; // For sprintf.
|
||||
ec = boost::system::error_code();
|
||||
char prefix_len[16];
|
||||
#if defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
#if defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
snprintf(prefix_len, sizeof(prefix_len), "/%u", prefix_length_);
|
||||
#elif defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
sprintf_s(prefix_len, sizeof(prefix_len), "/%u", prefix_length_);
|
||||
#else // defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
sprintf(prefix_len, "/%u", prefix_length_);
|
||||
|
||||
@@ -99,7 +99,9 @@ std::string network_v6::to_string(boost::system::error_code& ec) const
|
||||
using namespace std; // For sprintf.
|
||||
ec = boost::system::error_code();
|
||||
char prefix_len[16];
|
||||
#if defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
#if defined(BOOST_ASIO_HAS_SNPRINTF)
|
||||
snprintf(prefix_len, sizeof(prefix_len), "/%u", prefix_length_);
|
||||
#elif defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
sprintf_s(prefix_len, sizeof(prefix_len), "/%u", prefix_length_);
|
||||
#else // defined(BOOST_ASIO_HAS_SECURE_RTL)
|
||||
sprintf(prefix_len, "/%u", prefix_length_);
|
||||
|
||||
Reference in New Issue
Block a user