diff --git a/oscpack/ip/IpEndpointName.cpp b/oscpack/ip/IpEndpointName.cpp index 50b0262..d1c3b18 100644 --- a/oscpack/ip/IpEndpointName.cpp +++ b/oscpack/ip/IpEndpointName.cpp @@ -50,9 +50,11 @@ unsigned long IpEndpointName::GetHostByName( const char *s ) void IpEndpointName::AddressAsString( char *s ) const { if( address == ANY_ADDRESS ){ - std::sprintf( s, "" ); + //std::sprintf( s, "" ); + sprintf_s(s, ADDRESS_STRING_LENGTH, ""); }else{ - std::sprintf( s, "%d.%d.%d.%d", + //std::sprintf( s, "%d.%d.%d.%d", + sprintf_s(s, ADDRESS_STRING_LENGTH, "%d.%d.%d.%d", (int)((address >> 24) & 0xFF), (int)((address >> 16) & 0xFF), (int)((address >> 8) & 0xFF), @@ -65,9 +67,11 @@ void IpEndpointName::AddressAndPortAsString( char *s ) const { if( port == ANY_PORT ){ if( address == ANY_ADDRESS ){ - std::sprintf( s, ":" ); + //std::sprintf( s, ":" ); + sprintf_s(s, ADDRESS_AND_PORT_STRING_LENGTH, ":"); }else{ - std::sprintf( s, "%d.%d.%d.%d:", + //std::sprintf( s, "%d.%d.%d.%d:", + sprintf_s(s, ADDRESS_AND_PORT_STRING_LENGTH, "%d.%d.%d.%d:", (int)((address >> 24) & 0xFF), (int)((address >> 16) & 0xFF), (int)((address >> 8) & 0xFF), @@ -75,9 +79,11 @@ void IpEndpointName::AddressAndPortAsString( char *s ) const } }else{ if( address == ANY_ADDRESS ){ - std::sprintf( s, ":%d", port ); + //std::sprintf( s, ":%d", port ); + sprintf_s(s, ADDRESS_AND_PORT_STRING_LENGTH, ":%d", port); }else{ - std::sprintf( s, "%d.%d.%d.%d:%d", + //std::sprintf( s, "%d.%d.%d.%d:%d", + sprintf_s(s, ADDRESS_AND_PORT_STRING_LENGTH, "%d.%d.%d.%d:%d", (int)((address >> 24) & 0xFF), (int)((address >> 16) & 0xFF), (int)((address >> 8) & 0xFF), diff --git a/oscpack/osc/OscOutboundPacketStream.cpp b/oscpack/osc/OscOutboundPacketStream.cpp index b474b4f..8491e94 100644 --- a/oscpack/osc/OscOutboundPacketStream.cpp +++ b/oscpack/osc/OscOutboundPacketStream.cpp @@ -360,8 +360,9 @@ OutboundPacketStream& OutboundPacketStream::operator<<( const BeginMessage& rhs messageCursor_ = BeginElement( messageCursor_ ); - std::strcpy( messageCursor_, rhs.addressPattern ); + //std::strcpy( messageCursor_, rhs.addressPattern ); std::size_t rhsLength = std::strlen(rhs.addressPattern); + strcpy_s(messageCursor_, rhsLength, rhs.addressPattern); messageCursor_ += rhsLength + 1; // zero pad to 4-byte boundary @@ -602,8 +603,9 @@ OutboundPacketStream& OutboundPacketStream::operator<<( const char *rhs ) CheckForAvailableArgumentSpace( RoundUp4(std::strlen(rhs) + 1) ); *(--typeTagsCurrent_) = STRING_TYPE_TAG; - std::strcpy( argumentCurrent_, rhs ); + //std::strcpy( argumentCurrent_, rhs ); std::size_t rhsLength = std::strlen(rhs); + strcpy_s(argumentCurrent_, rhsLength, rhs); argumentCurrent_ += rhsLength + 1; // zero pad to 4-byte boundary @@ -622,8 +624,9 @@ OutboundPacketStream& OutboundPacketStream::operator<<( const Symbol& rhs ) CheckForAvailableArgumentSpace( RoundUp4(std::strlen(rhs) + 1) ); *(--typeTagsCurrent_) = SYMBOL_TYPE_TAG; - std::strcpy( argumentCurrent_, rhs ); + //std::strcpy( argumentCurrent_, rhs ); std::size_t rhsLength = std::strlen(rhs); + strcpy_s(argumentCurrent_, rhsLength, rhs); argumentCurrent_ += rhsLength + 1; // zero pad to 4-byte boundary diff --git a/oscpack/osc/OscPrintReceivedElements.cpp b/oscpack/osc/OscPrintReceivedElements.cpp index bc1689b..aed1de8 100644 --- a/oscpack/osc/OscPrintReceivedElements.cpp +++ b/oscpack/osc/OscPrintReceivedElements.cpp @@ -126,11 +126,14 @@ std::ostream& operator<<( std::ostream & os, std::time_t t = (unsigned long)( arg.AsTimeTagUnchecked() >> 32 ); - const char *timeString = std::ctime( &t ); - size_t len = std::strlen( timeString ); + //const char *timeString = std::ctime( &t ); + + const size_t len = 26; //26 chars needed for ctime_s + char timeString[len]; + errno_t err = ctime_s(timeString, len, &t); // -1 to omit trailing newline from string returned by ctime() - if( len > 1 ) + if( !err ) os.write( timeString, len - 1 ); } break; diff --git a/oscpack/oscpack.vcxproj b/oscpack/oscpack.vcxproj index 4e46eb0..c83cc76 100644 --- a/oscpack/oscpack.vcxproj +++ b/oscpack/oscpack.vcxproj @@ -121,7 +121,7 @@ Level3 true - _DEBUG;_LIB;__WIN32__;_WINSOCK_DEPRECATED_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + _DEBUG;_LIB;__WIN32__;%(PreprocessorDefinitions) true Use pch.h