From c92c08ff31dd8df21d09f519ac3ead4fe5b76f4e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 29 Jul 2012 18:38:55 +0200 Subject: [PATCH] Replace strcpys with strlcpy (except for librsound.c) --- xbox1/frontend/RetroLaunch/IoSupport.cpp | 2 +- xdk/xdk_resources.cpp | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/xbox1/frontend/RetroLaunch/IoSupport.cpp b/xbox1/frontend/RetroLaunch/IoSupport.cpp index cfeea542f5..53fc5c6528 100644 --- a/xbox1/frontend/RetroLaunch/IoSupport.cpp +++ b/xbox1/frontend/RetroLaunch/IoSupport.cpp @@ -120,7 +120,7 @@ HRESULT CIoSupport::Remount(CHAR* szDrive, CHAR* szDevice) HRESULT CIoSupport::Remap(CHAR* szMapping) { char szMap[32]; - strcpy(szMap, szMapping ); + strlcpy(szMap, szMapping, sizeof(szMap)); char* pComma = strstr(szMap, ","); if (pComma) diff --git a/xdk/xdk_resources.cpp b/xdk/xdk_resources.cpp index f39e4f9ca5..285132f83d 100644 --- a/xdk/xdk_resources.cpp +++ b/xdk/xdk_resources.cpp @@ -92,7 +92,8 @@ static __forceinline void FreeContiguousMemory( void* pData ) #ifdef _XBOX1 char g_strMediaPath[512] = "D:\\Media\\"; -static HRESULT FindMediaFile( char *strPath, const char *strFilename ) + +static HRESULT FindMediaFile( char *strPath, const char *strFilename, size_t strPathsize) { // Check for valid arguments if( strFilename == NULL || strPath == NULL ) @@ -102,7 +103,7 @@ static HRESULT FindMediaFile( char *strPath, const char *strFilename ) } // Default path is the filename itself as a fully qualified path - strcpy( strPath, strFilename ); + strlcpy( strPath, strFilename, strPathsize); // Check for the ':' character to see if the filename is a fully // qualified path. If not, pre-pend the media directory @@ -115,11 +116,7 @@ static HRESULT FindMediaFile( char *strPath, const char *strFilename ) if( hFile == INVALID_HANDLE_VALUE ) { - // Return error - CHAR strBuffer[80]; - sprintf( strBuffer, "FindMediaFile(): Could not find file [%s]\n", - strFilename ); - RARCH_ERR( strBuffer ); + RARCH_ERR("FindMediaFile(): Could not find file.\n"); return 0x82000004; } @@ -143,7 +140,7 @@ HRESULT PackedResource::Create( const char *strFilename ) // Find the media file CHAR strResourcePath[512]; - if( FAILED( FindMediaFile( strResourcePath, strFilename ) ) ) + if( FAILED(FindMediaFile(strResourcePath, strFilename, sizeof(strResourcePath)))) return E_FAIL; else strFilename = strResourcePath;