(Xbox 1) Change sprintfs to snprintfs

This commit is contained in:
twinaphex 2012-07-29 18:46:52 +02:00
parent c92c08ff31
commit d7fc00757d
4 changed files with 20 additions and 24 deletions

View File

@ -28,13 +28,13 @@ CIoSupport::~CIoSupport()
// szDrive e.g. "D:"
// szDevice e.g. "Cdrom0" or "Harddisk0\Partition6"
HRESULT CIoSupport::Mount(CHAR* szDrive, CHAR* szDevice)
HRESULT CIoSupport::Mount(char *szDrive, char *szDevice)
{
CHAR szSourceDevice[48];
CHAR szDestinationDrive[16];
char szSourceDevice[48];
char szDestinationDrive[16];
sprintf(szSourceDevice, "\\Device\\%s", szDevice);
sprintf(szDestinationDrive, "\\??\\%s", szDrive);
snprintf(szSourceDevice, sizeof(szSourceDevice), "\\Device\\%s", szDevice);
snprintf(szDestinationDrive, sizeof(szDestinationDrive), "\\??\\%s", szDrive);
STRING DeviceName =
{
@ -59,10 +59,10 @@ HRESULT CIoSupport::Mount(CHAR* szDrive, CHAR* szDevice)
// szDrive e.g. "D:"
HRESULT CIoSupport::Unmount(CHAR* szDrive)
HRESULT CIoSupport::Unmount(char *szDrive)
{
char szDestinationDrive[16];
sprintf(szDestinationDrive, "\\??\\%s", szDrive);
snprintf(szDestinationDrive, sizeof(szDestinationDrive), "\\??\\%s", szDrive);
STRING LinkName =
{
@ -76,14 +76,10 @@ HRESULT CIoSupport::Unmount(CHAR* szDrive)
return S_OK;
}
HRESULT CIoSupport::Remount(CHAR* szDrive, CHAR* szDevice)
HRESULT CIoSupport::Remount(char *szDrive, char *szDevice)
{
CHAR szSourceDevice[48];
sprintf(szSourceDevice, "\\Device\\%s", szDevice);
char szSourceDevice[48];
snprintf(szSourceDevice, sizeof(szSourceDevice), "\\Device\\%s", szDevice);
Unmount(szDrive);
@ -117,12 +113,12 @@ HRESULT CIoSupport::Remount(CHAR* szDrive, CHAR* szDevice)
return S_OK;
}
HRESULT CIoSupport::Remap(CHAR* szMapping)
HRESULT CIoSupport::Remap(char *szMapping)
{
char szMap[32];
strlcpy(szMap, szMapping, sizeof(szMap));
char* pComma = strstr(szMap, ",");
char *pComma = strstr(szMap, ",");
if (pComma)
{
*pComma = 0;

View File

@ -28,11 +28,11 @@ public:
CIoSupport();
virtual ~CIoSupport();
HRESULT Mount(CHAR* szDrive, CHAR* szDevice);
HRESULT Unmount(CHAR* szDrive);
HRESULT Mount(char *szDrive, char *szDevice);
HRESULT Unmount(char *szDrive);
HRESULT Remount(CHAR* szDrive, CHAR* szDevice);
HRESULT Remap(CHAR* szMapping);
HRESULT Remount(char *szDrive, char *szDevice);
HRESULT Remap(char *szMapping);
DWORD GetTrayState();
HRESULT EjectTray();

View File

@ -454,7 +454,7 @@ static bool xdk_d3d_frame(void *data, const void *frame,
char buf[128], buf2[128], buf_fps_last[128];
bool ret = false;
sprintf(buf, "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
snprintf(buf, sizeof(buf), "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
convert_char_to_wchar(strw_buffer, buf, sizeof(strw_buffer));
d3d->debug_font->TextOut(d3d->pFrontBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 50 );
d3d->debug_font->TextOut(d3d->pBackBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 50 );
@ -463,7 +463,7 @@ static bool xdk_d3d_frame(void *data, const void *frame,
{
if(ret)
{
sprintf(buf_fps_last, buf2);
snprintf(buf_fps_last, sizeof(buf_fps_last), buf2);
convert_char_to_wchar(strw_buffer, buf2, sizeof(strw_buffer));
}
else if(buf_fps_last)

View File

@ -107,8 +107,8 @@ static HRESULT FindMediaFile( char *strPath, const char *strFilename, size_t str
// Check for the ':' character to see if the filename is a fully
// qualified path. If not, pre-pend the media directory
if( strFilename[1] != ':' )
sprintf( strPath, "%s%s", g_strMediaPath, strFilename );
if(strFilename[1] != ':')
snprintf(strPath, strPathsize, "%s%s", g_strMediaPath, strFilename);
// Try to open the file
HANDLE hFile = CreateFile( strPath, GENERIC_READ, FILE_SHARE_READ, NULL,