From c01f392a7ba1d5cdd4aa182eeb273cf41717d94f Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 14 Jul 2014 17:34:26 +0200 Subject: Static Code Analysis : Use Safe String function in Dlgcode.c. Add byte size parameter in various functions to help implement secure handling of strings. --- src/Common/Dlgcode.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/Common/Dlgcode.h') diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index 588fea41..11686f89 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -222,9 +222,9 @@ typedef struct void cleanup ( void ); void LowerCaseCopy ( char *lpszDest , const char *lpszSource ); -void UpperCaseCopy ( char *lpszDest , const char *lpszSource ); -void CreateFullVolumePath ( char *lpszDiskFile , const char *lpszFileName , BOOL *bDevice ); -int FakeDosNameForDevice ( const char *lpszDiskFile , char *lpszDosDevice , char *lpszCFDevice , BOOL bNameOnly ); +void UpperCaseCopy ( char *lpszDest , size_t cbDest, const char *lpszSource ); +void CreateFullVolumePath ( char *lpszDiskFile , size_t cbDiskFile, const char *lpszFileName , BOOL *bDevice ); +int FakeDosNameForDevice ( const char *lpszDiskFile , char *lpszDosDevice , size_t cbDosDevice, char *lpszCFDevice , size_t cbCFDevice, BOOL bNameOnly ); int RemoveFakeDosName ( char *lpszDiskFile , char *lpszDosDevice ); void AbortProcess ( char *stringId ); void AbortProcessSilent ( void ); @@ -242,8 +242,8 @@ void CloseStaticModelessWaitDlg (void); BOOL IsButtonChecked ( HWND hButton ); void CheckButton ( HWND hButton ); void LeftPadString (char *szTmp, int len, int targetLen, char filler); -void ToSBCS ( LPWSTR lpszText ); -void ToUNICODE ( char *lpszText ); +void ToSBCS ( LPWSTR lpszText, size_t cbSize ); +void ToUNICODE ( char *lpszText , size_t cbSize); void InitDialog ( HWND hwndDlg ); void ProcessPaintMessages (HWND hwnd, int maxMessagesToProcess); HDC CreateMemBitmap ( HINSTANCE hInstance , HWND hwnd , char *resource ); @@ -293,7 +293,7 @@ BOOL OpenDevice (const char *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFile void NotifyDriverOfPortableMode (void); int GetAvailableFixedDisks ( HWND hComboBox , char *lpszRootPath ); int GetAvailableRemovables ( HWND hComboBox , char *lpszRootPath ); -int IsSystemDevicePath (char *path, HWND hwndDlg, BOOL bReliableRequired); +int IsSystemDevicePath (const char *path, HWND hwndDlg, BOOL bReliableRequired); BOOL CALLBACK RawDevicesDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam ); BOOL TextInfoDialogBox (int nID); BOOL CALLBACK TextInfoDialogBoxDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); @@ -333,7 +333,7 @@ int GetMountedVolumeDriveNo (char *volname); BOOL IsAdmin (void); BOOL IsBuiltInAdmin (); BOOL IsUacSupported (); -BOOL ResolveSymbolicLink (const wchar_t *symLinkName, PWSTR targetName); +BOOL ResolveSymbolicLink (const wchar_t *symLinkName, PWSTR targetName, size_t cbTargetName); int GetDiskDeviceDriveLetter (PWSTR deviceName); int FileSystemAppearsEmpty (const char *devicePath); __int64 GetStatsFreeSpaceOnPartition (const char *devicePath, float *percent, __int64 *occupiedBytes, BOOL silent); @@ -346,7 +346,7 @@ BOOL TCCopyFile (char *sourceFileName, char *destinationFile); BOOL SaveBufferToFile (const char *inputBuffer, const char *destinationFile, DWORD inputLength, BOOL bAppend); BOOL TCFlushFile (FILE *f); BOOL PrintHardCopyTextUTF16 (wchar_t *text, char *title, int byteLen); -void GetSpeedString (unsigned __int64 speed, wchar_t *str); +void GetSpeedString (unsigned __int64 speed, wchar_t *str, size_t cbStr); BOOL IsNonInstallMode (); BOOL DriverUnload (); LRESULT SetCheckBox (HWND hwndDlg, int dlgItem, BOOL state); @@ -362,7 +362,7 @@ LRESULT ListSubItemSet (HWND list, int index, int subIndex, char *string); LRESULT ListSubItemSetW (HWND list, int index, int subIndex, wchar_t *string); BOOL GetMountList (MOUNT_LIST_STRUCT *list); int GetDriverRefCount (); -void GetSizeString (unsigned __int64 size, wchar_t *str); +void GetSizeString (unsigned __int64 size, wchar_t *str, size_t cbStr); __int64 GetFileSize64 (const char *path); BOOL LoadInt16 (char *filePath, int *result, __int64 fileOffset); BOOL LoadInt32 (char *filePath, unsigned __int32 *result, __int64 fileOffset); @@ -429,8 +429,8 @@ BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam); BYTE *MapResource (char *resourceType, int resourceId, PDWORD size); void InconsistencyResolved (char *msg); void ReportUnexpectedState (char *techInfo); -BOOL SelectMultipleFiles (HWND hwndDlg, char *stringId, char *lpszFileName, BOOL keepHistory); -BOOL SelectMultipleFilesNext (char *lpszFileName); +BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, char *lpszFileName, size_t cbFileName, BOOL keepHistory); +BOOL SelectMultipleFilesNext (char *lpszFileName, size_t cbFileName); void OpenOnlineHelp (); BOOL GetPartitionInfo (const char *deviceName, PPARTITION_INFORMATION rpartInfo); BOOL GetDeviceInfo (const char *deviceName, DISK_PARTITION_INFO_STRUCT *info); @@ -464,7 +464,7 @@ int AskNonSysInPlaceEncryptionResume (); BOOL RemoveDeviceWriteProtection (HWND hwndDlg, char *devicePath); void EnableElevatedCursorChange (HWND parent); BOOL DisableFileCompression (HANDLE file); -BOOL VolumePathExists (char *volumePath); +BOOL VolumePathExists (const char *volumePath); BOOL IsWindowsIsoBurnerAvailable (); BOOL LaunchWindowsIsoBurner (HWND hwnd, const char *isoPath); BOOL IsApplicationInstalled (const char *appName); -- cgit v1.2.3