[misc] add static_strcat & static_strcpy and use static_ calls wherever possible

* Also set Rufus next to 2.17 and fix a warning
This commit is contained in:
Pete Batard 2017-08-10 19:43:04 +01:00
parent 5d371088cb
commit 90dc847e24
23 changed files with 121 additions and 120 deletions

20
configure vendored
View File

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for rufus 2.16. # Generated by GNU Autoconf 2.69 for rufus 2.17.
# #
# Report bugs to <https://github.com/pbatard/rufus/issues>. # Report bugs to <https://github.com/pbatard/rufus/issues>.
# #
@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='rufus' PACKAGE_NAME='rufus'
PACKAGE_TARNAME='rufus' PACKAGE_TARNAME='rufus'
PACKAGE_VERSION='2.16' PACKAGE_VERSION='2.17'
PACKAGE_STRING='rufus 2.16' PACKAGE_STRING='rufus 2.17'
PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues' PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues'
PACKAGE_URL='https://rufus.akeo.ie' PACKAGE_URL='https://rufus.akeo.ie'
@ -1228,7 +1228,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures rufus 2.16 to adapt to many kinds of systems. \`configure' configures rufus 2.17 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1294,7 +1294,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of rufus 2.16:";; short | recursive ) echo "Configuration of rufus 2.17:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1385,7 +1385,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
rufus configure 2.16 rufus configure 2.17
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1440,7 +1440,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by rufus $as_me 2.16, which was It was created by rufus $as_me 2.17, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -2303,7 +2303,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='rufus' PACKAGE='rufus'
VERSION='2.16' VERSION='2.17'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -4483,7 +4483,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by rufus $as_me 2.16, which was This file was extended by rufus $as_me 2.17, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -4537,7 +4537,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
rufus config.status 2.16 rufus config.status 2.17
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -1,4 +1,4 @@
AC_INIT([rufus], [2.16], [https://github.com/pbatard/rufus/issues], [rufus], [https://rufus.akeo.ie]) AC_INIT([rufus], [2.17], [https://github.com/pbatard/rufus/issues], [rufus], [https://rufus.akeo.ie])
AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies]) AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies])
AC_CONFIG_SRCDIR([src/rufus.c]) AC_CONFIG_SRCDIR([src/rufus.c])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])

View File

@ -8,7 +8,7 @@
for an interesting struggle, when you also happen to have a comma in one of the fields... --> for an interesting struggle, when you also happen to have a comma in one of the fields... -->
<Identity <Identity
Name="Rufus" Name="Rufus"
Version="2.16.1170.0" Version="2.17.1170.0"
ProcessorArchitecture="x86" ProcessorArchitecture="x86"
Publisher='CN=Akeo Consulting, O=Akeo Consulting, STREET="24, Grey Rock", L=Milford, S=Co Donegal, PostalCode=Co Donegal, C=IE' /> Publisher='CN=Akeo Consulting, O=Akeo Consulting, STREET="24, Grey Rock", L=Milford, S=Co Donegal, PostalCode=Co Donegal, C=IE' />
<Properties> <Properties>

View File

@ -1,5 +1,5 @@
@echo off @echo off
set VERSION=2.16 set VERSION=2.17
rem Make sure you don't have anything you don't want included in the package, as anything residing in the rem Make sure you don't have anything you don't want included in the package, as anything residing in the
rem current directory will be included, including any previous .appx, which makes for nice recursion... rem current directory will be included, including any previous .appx, which makes for nice recursion...

View File

@ -184,7 +184,7 @@ BOOL GetOpticalMedia(IMG_SAVE* img_save)
if (!SetupDiGetDeviceRegistryPropertyU(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME, if (!SetupDiGetDeviceRegistryPropertyU(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME,
&datatype, (LPBYTE)str, sizeof(str), &size)) { &datatype, (LPBYTE)str, sizeof(str), &size)) {
uprintf("SetupDiGetDeviceRegistryProperty (Friendly Name) failed: %s\n", WindowsErrorString()); uprintf("SetupDiGetDeviceRegistryProperty (Friendly Name) failed: %s\n", WindowsErrorString());
safe_strcpy(str, sizeof(str), "Generic Optical Drive"); static_strcpy(str, "Generic Optical Drive");
} }
uprintf("Found '%s' optical device", str); uprintf("Found '%s' optical device", str);
devint_data.cbSize = sizeof(devint_data); devint_data.cbSize = sizeof(devint_data);
@ -245,7 +245,7 @@ BOOL GetOpticalMedia(IMG_SAVE* img_save)
label[k] = 0; label[k] = 0;
img_save->Label = label; img_save->Label = label;
} }
safe_strcpy(str, sizeof(str), devint_detail_data->DevicePath); static_strcpy(str, devint_detail_data->DevicePath);
img_save->DevicePath = str; img_save->DevicePath = str;
img_save->DeviceSize = DiskGeometry->DiskSize.QuadPart; img_save->DeviceSize = DiskGeometry->DiskSize.QuadPart;
safe_closehandle(hDrive); safe_closehandle(hDrive);
@ -507,7 +507,7 @@ BOOL GetDevices(DWORD devnum)
&datatype, (LPBYTE)buffer, sizeof(buffer), &size)) { &datatype, (LPBYTE)buffer, sizeof(buffer), &size)) {
uprintf("SetupDiGetDeviceRegistryProperty (Friendly Name) failed: %s\n", WindowsErrorString()); uprintf("SetupDiGetDeviceRegistryProperty (Friendly Name) failed: %s\n", WindowsErrorString());
// We can afford a failure on this call - just replace the name with "USB Storage Device (Generic)" // We can afford a failure on this call - just replace the name with "USB Storage Device (Generic)"
safe_strcpy(buffer, sizeof(buffer), lmprintf(MSG_045)); static_strcpy(buffer, lmprintf(MSG_045));
} else if ((!props.is_VHD) && (devid_list != NULL)) { } else if ((!props.is_VHD) && (devid_list != NULL)) {
// Get the properties of the device. We could avoid doing this lookup every time by keeping // Get the properties of the device. We could avoid doing this lookup every time by keeping
// a lookup table, but there shouldn't be that many USB storage devices connected... // a lookup table, but there shouldn't be that many USB storage devices connected...
@ -580,7 +580,7 @@ BOOL GetDevices(DWORD devnum)
#ifdef FORCED_DEVICE #ifdef FORCED_DEVICE
props.vid = FORCED_VID; props.vid = FORCED_VID;
props.pid = FORCED_PID; props.pid = FORCED_PID;
safe_strcpy(buffer, sizeof(buffer), FORCED_NAME); static_strcpy(buffer, FORCED_NAME);
#endif #endif
} }
break; break;
@ -605,7 +605,7 @@ BOOL GetDevices(DWORD devnum)
uuprintf("Found non-USB non-removable device '%s' => Eliminated", buffer); uuprintf("Found non-USB non-removable device '%s' => Eliminated", buffer);
continue; continue;
} }
safe_strcpy(str, sizeof(str), "????:????"); // Couldn't figure VID:PID static_strcpy(str, "????:????"); // Couldn't figure VID:PID
} else { } else {
static_sprintf(str, "%04X:%04X", props.vid, props.pid); static_sprintf(str, "%04X:%04X", props.vid, props.pid);
} }
@ -731,14 +731,14 @@ BOOL GetDevices(DWORD devnum)
} }
// We have multiple volumes assigned to the same device (multiple partitions) // We have multiple volumes assigned to the same device (multiple partitions)
// If that is the case, use "Multiple Volumes" instead of the label // If that is the case, use "Multiple Volumes" instead of the label
safe_strcpy(entry_msg, sizeof(entry_msg), (((drive_letters[0] != 0) && (drive_letters[1] != 0))? static_strcpy(entry_msg, (((drive_letters[0] != 0) && (drive_letters[1] != 0))?
lmprintf(MSG_047):label)); lmprintf(MSG_047):label));
for (k=0, remove_drive=0; drive_letters[k] && (!remove_drive); k++) { for (k=0, remove_drive=0; drive_letters[k] && (!remove_drive); k++) {
// Append all the drive letters we detected // Append all the drive letters we detected
letter_name[2] = drive_letters[k]; letter_name[2] = drive_letters[k];
if (right_to_left_mode) if (right_to_left_mode)
safe_strcat(entry_msg, sizeof(entry_msg), RIGHT_TO_LEFT_MARK); static_strcat(entry_msg, RIGHT_TO_LEFT_MARK);
safe_strcat(entry_msg, sizeof(entry_msg), letter_name); static_strcat(entry_msg, letter_name);
if (drive_letters[k] == (PathGetDriveNumberU(app_dir) + 'A')) if (drive_letters[k] == (PathGetDriveNumberU(app_dir) + 'A'))
remove_drive = 1; remove_drive = 1;
if (drive_letters[k] == (PathGetDriveNumberU(system_dir) + 'A')) if (drive_letters[k] == (PathGetDriveNumberU(system_dir) + 'A'))

View File

@ -301,8 +301,8 @@ static BOOL ExtractMSDOS(const char* path)
return FALSE; return FALSE;
// Reduce the visible mess by placing all the locale files into a subdir // Reduce the visible mess by placing all the locale files into a subdir
safe_strcpy(locale_path, sizeof(locale_path), path); static_strcpy(locale_path, path);
safe_strcat(locale_path, sizeof(locale_path), "LOCALE\\"); static_strcat(locale_path, "LOCALE\\");
CreateDirectoryA(locale_path, NULL); CreateDirectoryA(locale_path, NULL);
len = GetSystemDirectoryA(dllname, sizeof(dllname)); len = GetSystemDirectoryA(dllname, sizeof(dllname));
@ -310,7 +310,7 @@ static BOOL ExtractMSDOS(const char* path)
uprintf("Unable to get system directory: %s\n", WindowsErrorString()); uprintf("Unable to get system directory: %s\n", WindowsErrorString());
goto out; goto out;
} }
safe_strcat(dllname, sizeof(dllname), "\\diskcopy.dll"); static_strcat(dllname, "\\diskcopy.dll");
hDLL = LoadLibraryA(dllname); hDLL = LoadLibraryA(dllname);
if (hDLL == NULL) { if (hDLL == NULL) {
uprintf("Unable to open %s: %s\n", dllname, WindowsErrorString()); uprintf("Unable to open %s: %s\n", dllname, WindowsErrorString());
@ -375,15 +375,15 @@ BOOL ExtractFreeDOS(const char* path)
} }
// Reduce the visible mess by placing all the locale files into a subdir // Reduce the visible mess by placing all the locale files into a subdir
safe_strcpy(locale_path, sizeof(locale_path), path); static_strcpy(locale_path, path);
safe_strcat(locale_path, sizeof(locale_path), "LOCALE\\"); static_strcat(locale_path, "LOCALE\\");
CreateDirectoryA(locale_path, NULL); CreateDirectoryA(locale_path, NULL);
for (i=0; i<ARRAYSIZE(res_name); i++) { for (i=0; i<ARRAYSIZE(res_name); i++) {
res_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(res_id[i]), _RT_RCDATA, res_name[i], &res_size, FALSE); res_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(res_id[i]), _RT_RCDATA, res_name[i], &res_size, FALSE);
safe_strcpy(filename, sizeof(filename), ((i<2)?path:locale_path)); static_strcpy(filename, ((i<2)?path:locale_path));
safe_strcat(filename, sizeof(filename), res_name[i]); static_strcat(filename, res_name[i]);
hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, hFile = CreateFileA(filename, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL,
CREATE_ALWAYS, (i<2)?(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM):FILE_ATTRIBUTE_NORMAL, NULL); CREATE_ALWAYS, (i<2)?(FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM):FILE_ATTRIBUTE_NORMAL, NULL);

View File

@ -992,8 +992,8 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
if ((cp == 437) && (strcmp(kb, "us") == 0)) { if ((cp == 437) && (strcmp(kb, "us") == 0)) {
// Nothing much to do if US/US - just notify in autoexec.bat // Nothing much to do if US/US - just notify in autoexec.bat
safe_strcpy(filename, sizeof(filename), path); static_strcpy(filename, path);
safe_strcat(filename, sizeof(filename), "\\AUTOEXEC.BAT"); static_strcat(filename, "\\AUTOEXEC.BAT");
fd = fopen(filename, "w+"); fd = fopen(filename, "w+");
if (fd == NULL) { if (fd == NULL) {
uprintf("Unable to create 'AUTOEXEC.BAT': %s.\n", WindowsErrorString()); uprintf("Unable to create 'AUTOEXEC.BAT': %s.\n", WindowsErrorString());
@ -1008,8 +1008,8 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
} }
// CONFIG.SYS // CONFIG.SYS
safe_strcpy(filename, sizeof(filename), path); static_strcpy(filename, path);
safe_strcat(filename, sizeof(filename), "\\CONFIG.SYS"); static_strcat(filename, "\\CONFIG.SYS");
fd = fopen(filename, "w+"); fd = fopen(filename, "w+");
if (fd == NULL) { if (fd == NULL) {
uprintf("Unable to create 'CONFIG.SYS': %s.\n", WindowsErrorString()); uprintf("Unable to create 'CONFIG.SYS': %s.\n", WindowsErrorString());
@ -1033,8 +1033,8 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
uprintf("Successfully wrote 'CONFIG.SYS'\n"); uprintf("Successfully wrote 'CONFIG.SYS'\n");
// AUTOEXEC.BAT // AUTOEXEC.BAT
safe_strcpy(filename, sizeof(filename), path); static_strcpy(filename, path);
safe_strcat(filename, sizeof(filename), "\\AUTOEXEC.BAT"); static_strcat(filename, "\\AUTOEXEC.BAT");
fd = fopen(filename, "w+"); fd = fopen(filename, "w+");
if (fd == NULL) { if (fd == NULL) {
uprintf("Unable to create 'AUTOEXEC.BAT': %s.\n", WindowsErrorString()); uprintf("Unable to create 'AUTOEXEC.BAT': %s.\n", WindowsErrorString());

View File

@ -204,7 +204,7 @@ char* GetPhysicalName(DWORD DriveIndex)
char physical_name[24]; char physical_name[24];
CheckDriveIndex(DriveIndex); CheckDriveIndex(DriveIndex);
safe_sprintf(physical_name, sizeof(physical_name), "\\\\.\\PHYSICALDRIVE%lu", DriveIndex); static_sprintf(physical_name, "\\\\.\\PHYSICALDRIVE%lu", DriveIndex);
success = TRUE; success = TRUE;
out: out:
return (success)?safe_strdup(physical_name):NULL; return (success)?safe_strdup(physical_name):NULL;
@ -444,7 +444,7 @@ static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT*
if ((_drive_type != DRIVE_REMOVABLE) && (_drive_type != DRIVE_FIXED)) if ((_drive_type != DRIVE_REMOVABLE) && (_drive_type != DRIVE_FIXED))
continue; continue;
safe_sprintf(logical_drive, sizeof(logical_drive), "\\\\.\\%c:", drive[0]); static_sprintf(logical_drive, "\\\\.\\%c:", drive[0]);
hDrive = CreateFileA(logical_drive, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, hDrive = CreateFileA(logical_drive, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hDrive == INVALID_HANDLE_VALUE) { if (hDrive == INVALID_HANDLE_VALUE) {
@ -552,7 +552,7 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label)
safe_closehandle(hPhysical); safe_closehandle(hPhysical);
if (AutorunLabel != NULL) { if (AutorunLabel != NULL) {
uprintf("Using autorun.inf label for drive %c: '%s'\n", letters[0], AutorunLabel); uprintf("Using autorun.inf label for drive %c: '%s'\n", letters[0], AutorunLabel);
safe_strcpy(VolumeLabel, sizeof(VolumeLabel), AutorunLabel); static_strcpy(VolumeLabel, AutorunLabel);
safe_free(AutorunLabel); safe_free(AutorunLabel);
*label = VolumeLabel; *label = VolumeLabel;
} else if (GetVolumeInformationU(DrivePath, VolumeLabel, ARRAYSIZE(VolumeLabel), } else if (GetVolumeInformationU(DrivePath, VolumeLabel, ARRAYSIZE(VolumeLabel),

View File

@ -712,8 +712,8 @@ static BOOL FormatDrive(DWORD DriveIndex)
// Check if Windows picked the UEFI:NTFS partition // Check if Windows picked the UEFI:NTFS partition
// NB: No need to do this for Large FAT32, as this only applies to NTFS // NB: No need to do this for Large FAT32, as this only applies to NTFS
safe_strcpy(path, MAX_PATH, VolumeName); static_strcpy(path, VolumeName);
safe_strcat(path, MAX_PATH, "EFI\\Rufus\\ntfs_x64.efi"); static_strcat(path, "EFI\\Rufus\\ntfs_x64.efi");
if (PathFileExistsA(path)) { if (PathFileExistsA(path)) {
uprintf("Windows selected the UEFI:NTFS partition for formatting - Retry needed", VolumeName); uprintf("Windows selected the UEFI:NTFS partition for formatting - Retry needed", VolumeName);
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_RETRY; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_RETRY;
@ -1167,16 +1167,16 @@ static BOOL SetupWinPE(char drive_letter)
index = ((img_report.winpe&WINPE_I386) == WINPE_I386)?0:1; index = ((img_report.winpe&WINPE_I386) == WINPE_I386)?0:1;
// Allow other values than harddisk 1, as per user choice for disk ID // Allow other values than harddisk 1, as per user choice for disk ID
safe_sprintf(setupsrcdev, sizeof(setupsrcdev), static_sprintf(setupsrcdev, "SetupSourceDevice = \"\\device\\harddisk%d\\partition1\"",
"SetupSourceDevice = \"\\device\\harddisk%d\\partition1\"", ComboBox_GetCurSel(hDiskID)); ComboBox_GetCurSel(hDiskID));
// Copy of ntdetect.com in root // Copy of ntdetect.com in root
safe_sprintf(src, sizeof(src), "%c:\\%s\\ntdetect.com", drive_letter, basedir[index]); static_sprintf(src, "%c:\\%s\\ntdetect.com", drive_letter, basedir[index]);
safe_sprintf(dst, sizeof(dst), "%c:\\ntdetect.com", drive_letter); static_sprintf(dst, "%c:\\ntdetect.com", drive_letter);
CopyFileA(src, dst, TRUE); CopyFileA(src, dst, TRUE);
if (!img_report.uses_minint) { if (!img_report.uses_minint) {
// Create a copy of txtsetup.sif, as we want to keep the i386 files unmodified // Create a copy of txtsetup.sif, as we want to keep the i386 files unmodified
safe_sprintf(src, sizeof(src), "%c:\\%s\\txtsetup.sif", drive_letter, basedir[index]); static_sprintf(src, "%c:\\%s\\txtsetup.sif", drive_letter, basedir[index]);
safe_sprintf(dst, sizeof(dst), "%c:\\txtsetup.sif", drive_letter); static_sprintf(dst, "%c:\\txtsetup.sif", drive_letter);
if (!CopyFileA(src, dst, TRUE)) { if (!CopyFileA(src, dst, TRUE)) {
uprintf("Did not copy %s as %s: %s\n", src, dst, WindowsErrorString()); uprintf("Did not copy %s as %s: %s\n", src, dst, WindowsErrorString());
} }
@ -1187,8 +1187,8 @@ static BOOL SetupWinPE(char drive_letter)
uprintf("Successfully added '%s' to %s\n", setupsrcdev, dst); uprintf("Successfully added '%s' to %s\n", setupsrcdev, dst);
} }
safe_sprintf(src, sizeof(src), "%c:\\%s\\setupldr.bin", drive_letter, basedir[index]); static_sprintf(src, "%c:\\%s\\setupldr.bin", drive_letter, basedir[index]);
safe_sprintf(dst, sizeof(dst), "%c:\\BOOTMGR", drive_letter); static_sprintf(dst, "%c:\\BOOTMGR", drive_letter);
if (!CopyFileA(src, dst, TRUE)) { if (!CopyFileA(src, dst, TRUE)) {
uprintf("Did not copy %s as %s: %s\n", src, dst, WindowsErrorString()); uprintf("Did not copy %s as %s: %s\n", src, dst, WindowsErrorString());
} }
@ -1309,7 +1309,7 @@ int SetWinToGoIndex(void)
|| (GetTempFileNameU(tmp_path, APPLICATION_NAME, 0, xml_file) == 0) || (GetTempFileNameU(tmp_path, APPLICATION_NAME, 0, xml_file) == 0)
|| (xml_file[0] == 0)) { || (xml_file[0] == 0)) {
// Last ditch effort to get a tmp file - just extract it to the current directory // Last ditch effort to get a tmp file - just extract it to the current directory
safe_strcpy(xml_file, sizeof(xml_file), ".\\RufVXml.tmp"); static_strcpy(xml_file, ".\\RufVXml.tmp");
} }
// GetTempFileName() may leave a file behind // GetTempFileName() may leave a file behind
DeleteFileU(xml_file); DeleteFileU(xml_file);
@ -1771,7 +1771,7 @@ DWORD WINAPI FormatThread(void* param)
// create a log file for bad blocks report. Since %USERPROFILE% may // create a log file for bad blocks report. Since %USERPROFILE% may
// have localized characters, we use the UTF-8 API. // have localized characters, we use the UTF-8 API.
userdir = getenvU("USERPROFILE"); userdir = getenvU("USERPROFILE");
safe_strcpy(logfile, MAX_PATH, userdir); static_strcpy(logfile, userdir);
safe_free(userdir); safe_free(userdir);
GetLocalTime(&lt); GetLocalTime(&lt);
safe_sprintf(&logfile[strlen(logfile)], sizeof(logfile)-strlen(logfile)-1, safe_sprintf(&logfile[strlen(logfile)], sizeof(logfile)-strlen(logfile)-1,

View File

@ -160,7 +160,7 @@ BOOL SetAutorun(const char* path)
char filename[64]; char filename[64];
wchar_t wlabel[128], wRufusVersion[32]; wchar_t wlabel[128], wRufusVersion[32];
safe_sprintf(filename, sizeof(filename), "%sautorun.inf", path); static_sprintf(filename, "%sautorun.inf", path);
fd = fopen(filename, "r"); // If there's an existing autorun, don't overwrite fd = fopen(filename, "r"); // If there's an existing autorun, don't overwrite
if (fd != NULL) { if (fd != NULL) {
uprintf("%s already exists - keeping it", filename); uprintf("%s already exists - keeping it", filename);

View File

@ -202,11 +202,11 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t i_file_length, cons
// Check for ReactOS' setupldr.sys anywhere // Check for ReactOS' setupldr.sys anywhere
if ((img_report.reactos_path[0] == 0) && (safe_stricmp(psz_basename, reactos_name) == 0)) if ((img_report.reactos_path[0] == 0) && (safe_stricmp(psz_basename, reactos_name) == 0))
safe_strcpy(img_report.reactos_path, sizeof(img_report.reactos_path), psz_fullpath); static_strcpy(img_report.reactos_path, psz_fullpath);
// Check for the first 'efi.img' we can find (that hopefully contains EFI boot files) // Check for the first 'efi.img' we can find (that hopefully contains EFI boot files)
if (!HAS_EFI_IMG(img_report) && (safe_stricmp(psz_basename, efi_img_name) == 0)) if (!HAS_EFI_IMG(img_report) && (safe_stricmp(psz_basename, efi_img_name) == 0))
safe_strcpy(img_report.efi_img_path, sizeof(img_report.efi_img_path), psz_fullpath); static_strcpy(img_report.efi_img_path, psz_fullpath);
// Check for the EFI boot entries // Check for the EFI boot entries
if (safe_stricmp(psz_dirname, efi_dirname) == 0) { if (safe_stricmp(psz_dirname, efi_dirname) == 0) {
@ -632,7 +632,7 @@ void GetGrubVersion(char* buf, size_t buf_size)
for (i=0; i<buf_size; i++) { for (i=0; i<buf_size; i++) {
if (memcmp(&buf[i], grub_version_str, sizeof(grub_version_str)) == 0) { if (memcmp(&buf[i], grub_version_str, sizeof(grub_version_str)) == 0) {
safe_strcpy(img_report.grub2_version, sizeof(img_report.grub2_version), &buf[i + sizeof(grub_version_str)]); static_strcpy(img_report.grub2_version, &buf[i + sizeof(grub_version_str)]);
break; break;
} }
} }
@ -738,7 +738,7 @@ try_iso:
i_joliet_level = iso9660_ifs_get_joliet_level(p_iso); i_joliet_level = iso9660_ifs_get_joliet_level(p_iso);
if (scan_only) { if (scan_only) {
if (iso9660_ifs_get_volume_id(p_iso, &tmp)) { if (iso9660_ifs_get_volume_id(p_iso, &tmp)) {
safe_strcpy(img_report.label, sizeof(img_report.label), tmp); static_strcpy(img_report.label, tmp);
safe_free(tmp); safe_free(tmp);
} else } else
img_report.label[0] = 0; img_report.label[0] = 0;
@ -779,7 +779,7 @@ out:
// See https://github.com/openSUSE/kiwi/issues/354 // See https://github.com/openSUSE/kiwi/issues/354
if ( (_stricmp(config_path.String[i], "/boot/i386/loader/isolinux.cfg") == 0) || if ( (_stricmp(config_path.String[i], "/boot/i386/loader/isolinux.cfg") == 0) ||
(_stricmp(config_path.String[i], "/boot/x86_64/loader/isolinux.cfg") == 0)) { (_stricmp(config_path.String[i], "/boot/x86_64/loader/isolinux.cfg") == 0)) {
safe_strcpy(img_report.cfg_path, sizeof(img_report.cfg_path), config_path.String[i]); static_strcpy(img_report.cfg_path, config_path.String[i]);
img_report.needs_syslinux_overwrite = TRUE; img_report.needs_syslinux_overwrite = TRUE;
break; break;
} }
@ -789,7 +789,7 @@ out:
// We may have to revisit this and prefer a path that contains '/isolinux' if // We may have to revisit this and prefer a path that contains '/isolinux' if
// this hack is not enough for other images. // this hack is not enough for other images.
if (safe_strlen(img_report.cfg_path) >= safe_strlen(config_path.String[i])) if (safe_strlen(img_report.cfg_path) >= safe_strlen(config_path.String[i]))
safe_strcpy(img_report.cfg_path, sizeof(img_report.cfg_path), config_path.String[i]); static_strcpy(img_report.cfg_path, config_path.String[i]);
} }
uprintf(" Will use '%s' for Syslinux", img_report.cfg_path); uprintf(" Will use '%s' for Syslinux", img_report.cfg_path);
// Extract all of the isolinux.bin files we found to identify their versions // Extract all of the isolinux.bin files we found to identify their versions
@ -811,7 +811,7 @@ out:
fclose(fd); fclose(fd);
sl_version = GetSyslinuxVersion(buf, size, &ext); sl_version = GetSyslinuxVersion(buf, size, &ext);
if (img_report.sl_version == 0) { if (img_report.sl_version == 0) {
safe_strcpy(img_report.sl_version_ext, sizeof(img_report.sl_version_ext), ext); static_strcpy(img_report.sl_version_ext, ext);
img_report.sl_version = sl_version; img_report.sl_version = sl_version;
sl_index = i; sl_index = i;
} else if ((img_report.sl_version != sl_version) || (safe_strcmp(img_report.sl_version_ext, ext) != 0)) { } else if ((img_report.sl_version != sl_version) || (safe_strcmp(img_report.sl_version_ext, ext) != 0)) {
@ -822,7 +822,7 @@ out:
// Where possible, prefer to the one that resides in the same directory as the config file. // Where possible, prefer to the one that resides in the same directory as the config file.
for (j=safe_strlen(img_report.cfg_path); (j>0) && (img_report.cfg_path[j]!='/'); j--); for (j=safe_strlen(img_report.cfg_path); (j>0) && (img_report.cfg_path[j]!='/'); j--);
if (safe_strnicmp(img_report.cfg_path, isolinux_path.String[i], j) == 0) { if (safe_strnicmp(img_report.cfg_path, isolinux_path.String[i], j) == 0) {
safe_strcpy(img_report.sl_version_ext, sizeof(img_report.sl_version_ext), ext); static_strcpy(img_report.sl_version_ext, ext);
img_report.sl_version = sl_version; img_report.sl_version = sl_version;
sl_index = i; sl_index = i;
} }
@ -855,7 +855,7 @@ out:
// In case we have a WinPE 1.x based iso, we extract and parse txtsetup.sif // In case we have a WinPE 1.x based iso, we extract and parse txtsetup.sif
// during scan, to see if /minint was provided for OsLoadOptions, as it decides // during scan, to see if /minint was provided for OsLoadOptions, as it decides
// whether we should use 0x80 or 0x81 as the disk ID in the MBR // whether we should use 0x80 or 0x81 as the disk ID in the MBR
safe_sprintf(path, sizeof(path), "/%s/txtsetup.sif", static_sprintf(path, "/%s/txtsetup.sif",
basedir[((img_report.winpe&WINPE_I386) == WINPE_I386)?0:1]); basedir[((img_report.winpe&WINPE_I386) == WINPE_I386)?0:1]);
ExtractISOFile(src_iso, path, tmp_sif, FILE_ATTRIBUTE_NORMAL); ExtractISOFile(src_iso, path, tmp_sif, FILE_ATTRIBUTE_NORMAL);
tmp = get_token_data_file("OsLoadOptions", tmp_sif); tmp = get_token_data_file("OsLoadOptions", tmp_sif);
@ -903,13 +903,13 @@ out:
if (img_report.has_efi == 0x80) if (img_report.has_efi == 0x80)
ExtractEfiImgFiles(dest_dir); ExtractEfiImgFiles(dest_dir);
if (HAS_SYSLINUX(img_report)) { if (HAS_SYSLINUX(img_report)) {
safe_sprintf(path, sizeof(path), "%s\\syslinux.cfg", dest_dir); static_sprintf(path, "%s\\syslinux.cfg", dest_dir);
// Create a /syslinux.cfg (if none exists) that points to the existing isolinux cfg // Create a /syslinux.cfg (if none exists) that points to the existing isolinux cfg
fd = fopen(path, "r"); fd = fopen(path, "r");
if (fd != NULL && img_report.needs_syslinux_overwrite) { if (fd != NULL && img_report.needs_syslinux_overwrite) {
fclose(fd); fclose(fd);
fd = NULL; fd = NULL;
safe_sprintf(path2, sizeof(path2), "%s\\syslinux.org", dest_dir); static_sprintf(path2, "%s\\syslinux.org", dest_dir);
uprintf("Renaming: %s ➔ %s", path, path2); uprintf("Renaming: %s ➔ %s", path, path2);
IGNORE_RETVAL(rename(path, path2)); IGNORE_RETVAL(rename(path, path2));
} }
@ -1166,7 +1166,7 @@ BOOL ExtractEfiImgFiles(const char* dir)
iso9660_readfat_private* p_private = NULL; iso9660_readfat_private* p_private = NULL;
libfat_sector_t s; libfat_sector_t s;
int32_t dc, c; int32_t dc, c;
struct libfat_filesystem *fs; struct libfat_filesystem *fs = NULL;
struct libfat_direntry direntry; struct libfat_direntry direntry;
char name[12] = { 0 }; char name[12] = { 0 };
char path[64]; char path[64];
@ -1244,13 +1244,13 @@ BOOL ExtractEfiImgFiles(const char* dir)
uprintf("Could not create directory '%s': %s\n", path, WindowsErrorString()); uprintf("Could not create directory '%s': %s\n", path, WindowsErrorString());
continue; continue;
} }
safe_strcat(path, sizeof(path), "\\boot"); static_strcat(path, "\\boot");
if (!CreateDirectoryA(path, 0) && (GetLastError() != ERROR_ALREADY_EXISTS)) { if (!CreateDirectoryA(path, 0) && (GetLastError() != ERROR_ALREADY_EXISTS)) {
uprintf("Could not create directory '%s': %s\n", path, WindowsErrorString()); uprintf("Could not create directory '%s': %s\n", path, WindowsErrorString());
continue; continue;
} }
safe_strcat(path, sizeof(path), "\\"); static_strcat(path, "\\");
safe_strcat(path, sizeof(path), efi_bootname[i]); static_strcat(path, efi_bootname[i]);
uprintf("Extracting: %s (from '%s', %s)", path, img_report.efi_img_path, uprintf("Extracting: %s (from '%s', %s)", path, img_report.efi_img_path,
SizeToHumanReadable(file_size, FALSE, FALSE)); SizeToHumanReadable(file_size, FALSE, FALSE));
handle = CreateFileA(path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, handle = CreateFileA(path, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ,

View File

@ -205,7 +205,7 @@ const char* WinInetErrorString(void)
InternetGetLastResponseInfoA(&error_code, error_string, &size); InternetGetLastResponseInfoA(&error_code, error_string, &size);
return error_string; return error_string;
default: default:
safe_sprintf(error_string, sizeof(error_string), "Unknown internet error 0x%08lX", error_code); static_sprintf(error_string, "Unknown internet error 0x%08lX", error_code);
return error_string; return error_string;
} }
} }
@ -275,7 +275,7 @@ DWORD DownloadFile(const char* url, const char* file, HWND hProgressDialog)
uprintf("Network is unavailable: %s\n", WinInetErrorString()); uprintf("Network is unavailable: %s\n", WinInetErrorString());
goto out; goto out;
} }
safe_sprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d (Windows NT %d.%d%s)", static_sprintf(agent, APPLICATION_NAME "/%d.%d.%d (Windows NT %d.%d%s)",
rufus_version[0], rufus_version[1], rufus_version[2], rufus_version[0], rufus_version[1], rufus_version[2],
nWindowsVersion>>4, nWindowsVersion&0x0F, is_x64()?"; WOW64":""); nWindowsVersion>>4, nWindowsVersion&0x0F, is_x64()?"; WOW64":"");
hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
@ -467,7 +467,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
goto out; goto out;
hostname[sizeof(hostname)-1] = 0; hostname[sizeof(hostname)-1] = 0;
safe_sprintf(agent, ARRAYSIZE(agent), APPLICATION_NAME "/%d.%d.%d (Windows NT %d.%d%s)", static_sprintf(agent, APPLICATION_NAME "/%d.%d.%d (Windows NT %d.%d%s)",
rufus_version[0], rufus_version[1], rufus_version[2], rufus_version[0], rufus_version[1], rufus_version[2],
nWindowsVersion >> 4, nWindowsVersion & 0x0F, is_x64() ? "; WOW64" : ""); nWindowsVersion >> 4, nWindowsVersion & 0x0F, is_x64() ? "; WOW64" : "");
hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0); hSession = InternetOpenA(agent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
@ -493,7 +493,7 @@ static DWORD WINAPI CheckForUpdatesThread(LPVOID param)
// and then remove each each of the <os_> components until we find our match. For instance, we may first // and then remove each each of the <os_> components until we find our match. For instance, we may first
// look for rufus_win_x64_6.2.ver (Win8 x64) but only get a match for rufus_win_x64_6.ver (Vista x64 or later) // look for rufus_win_x64_6.2.ver (Win8 x64) but only get a match for rufus_win_x64_6.ver (Vista x64 or later)
// This allows sunsetting OS versions (eg XP) or providing different downloads for different archs/groups. // This allows sunsetting OS versions (eg XP) or providing different downloads for different archs/groups.
safe_sprintf(urlpath, sizeof(urlpath), "%s%s%s_%s_%lu.%lu.ver", APPLICATION_NAME, (k==0)?"":"_", static_sprintf(urlpath, "%s%s%s_%s_%lu.%lu.ver", APPLICATION_NAME, (k==0)?"":"_",
(k==0)?"":channel[k], archname[is_x64()?1:0], os_version.dwMajorVersion, os_version.dwMinorVersion); (k==0)?"":channel[k], archname[is_x64()?1:0], os_version.dwMajorVersion, os_version.dwMinorVersion);
vuprintf("Base update check: %s\n", urlpath); vuprintf("Base update check: %s\n", urlpath);
for (i=0, j=(int)safe_strlen(urlpath)-5; (j>0)&&(i<ARRAYSIZE(verpos)); j--) { for (i=0, j=(int)safe_strlen(urlpath)-5; (j>0)&&(i<ARRAYSIZE(verpos)); j--) {

View File

@ -104,7 +104,7 @@ static char* NtStatusError(NTSTATUS Status) {
case STATUS_NOT_SUPPORTED: case STATUS_NOT_SUPPORTED:
return "Operation is not supported"; return "Operation is not supported";
default: default:
safe_sprintf(unknown, sizeof(unknown), "Unknown error 0x%08lx", Status); static_sprintf(unknown, "Unknown error 0x%08lx", Status);
return unknown; return unknown;
} }
} }
@ -510,7 +510,7 @@ static DWORD WINAPI SearchProcessThread(LPVOID param)
// Complete failure => Just craft a default process name that includes the PID // Complete failure => Just craft a default process name that includes the PID
if (!bGotExePath) { if (!bGotExePath) {
safe_sprintf(exe_path, MAX_PATH, "Unknown_Process_%" PRIu64, static_sprintf(exe_path, "Unknown_Process_%" PRIu64,
(ULONGLONG)handleInfo->UniqueProcessId); (ULONGLONG)handleInfo->UniqueProcessId);
} }
} }

View File

@ -89,12 +89,12 @@ static __inline BOOL _GetRegistryKey(HKEY key_root, const char* key_name, DWORD
if (i + sizeof(software_prefix) >= sizeof(long_key_name)) if (i + sizeof(software_prefix) >= sizeof(long_key_name))
return FALSE; return FALSE;
strcpy(long_key_name, software_prefix); strcpy(long_key_name, software_prefix);
safe_strcat(long_key_name, sizeof(long_key_name), key_name); static_strcat(long_key_name, key_name);
long_key_name[sizeof(software_prefix) + i - 1] = 0; long_key_name[sizeof(software_prefix) + i - 1] = 0;
} else { } else {
if (i >= sizeof(long_key_name)) if (i >= sizeof(long_key_name))
return FALSE; return FALSE;
safe_strcpy(long_key_name, sizeof(long_key_name), key_name); static_strcpy(long_key_name, key_name);
long_key_name[i] = 0; long_key_name[i] = 0;
} }
i++; i++;
@ -164,12 +164,12 @@ static __inline BOOL _SetRegistryKey(HKEY key_root, const char* key_name, DWORD
if (i + sizeof(software_prefix) >= sizeof(long_key_name)) if (i + sizeof(software_prefix) >= sizeof(long_key_name))
goto out; goto out;
strcpy(long_key_name, software_prefix); strcpy(long_key_name, software_prefix);
safe_strcat(long_key_name, sizeof(long_key_name), key_name); static_strcat(long_key_name, key_name);
long_key_name[sizeof(software_prefix) + i - 1] = 0; long_key_name[sizeof(software_prefix) + i - 1] = 0;
} else { } else {
if (i >= sizeof(long_key_name)) if (i >= sizeof(long_key_name))
goto out; goto out;
safe_strcpy(long_key_name, sizeof(long_key_name), key_name); static_strcpy(long_key_name, key_name);
long_key_name[i] = 0; long_key_name[i] = 0;
} }
i++; i++;

View File

@ -305,8 +305,8 @@ static BOOL DefineClusterSizes(void)
tmp[0] = 0; tmp[0] = 0;
// Tell the user if we're going to use Large FAT32 or regular // Tell the user if we're going to use Large FAT32 or regular
if ((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32))) if ((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32)))
safe_strcat(tmp, sizeof(tmp), "Large "); static_strcat(tmp, "Large ");
safe_strcat(tmp, sizeof(tmp), FileSystemLabel[fs]); static_strcat(tmp, FileSystemLabel[fs]);
if (default_fs == FS_UNKNOWN) { if (default_fs == FS_UNKNOWN) {
entry = lmprintf(MSG_030, tmp); entry = lmprintf(MSG_030, tmp);
default_fs = fs; default_fs = fs;
@ -665,7 +665,7 @@ static BOOL PopulateProperties(int ComboIndex)
EnableBootOptions(TRUE, TRUE); EnableBootOptions(TRUE, TRUE);
// Set a proposed label according to the size (eg: "256MB", "8GB") // Set a proposed label according to the size (eg: "256MB", "8GB")
safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label), static_sprintf(SelectedDrive.proposed_label,
SizeToHumanReadable(SelectedDrive.DiskSize, FALSE, use_fake_units)); SizeToHumanReadable(SelectedDrive.DiskSize, FALSE, use_fake_units));
// Add a tooltip (with the size of the device in parenthesis) // Add a tooltip (with the size of the device in parenthesis)
@ -925,8 +925,7 @@ BOOL CALLBACK LogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
static void CALLBACK ClockTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) static void CALLBACK ClockTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{ {
timer++; timer++;
safe_sprintf(szTimer, sizeof(szTimer), "%02d:%02d:%02d", static_sprintf(szTimer, "%02d:%02d:%02d", timer/3600, (timer%3600)/60, timer%60);
timer/3600, (timer%3600)/60, timer%60);
SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer);
} }
@ -1402,7 +1401,7 @@ static BOOL BootCheck(void)
if ((grub2_len == 0) && (DownloadStatus == 404)) { if ((grub2_len == 0) && (DownloadStatus == 404)) {
// Couldn't locate the file on the server => try to download without the version extra // Couldn't locate the file on the server => try to download without the version extra
uprintf("Extended version was not found, trying main version..."); uprintf("Extended version was not found, trying main version...");
safe_strcpy(tmp2, sizeof(tmp2), img_report.grub2_version); static_strcpy(tmp2, img_report.grub2_version);
// Isolate the #.### part // Isolate the #.### part
for (i = 0; ((tmp2[i] >= '0') && (tmp2[i] <= '9')) || (tmp2[i] == '.'); i++); for (i = 0; ((tmp2[i] >= '0') && (tmp2[i] <= '9')) || (tmp2[i] == '.'); i++);
tmp2[i] = 0; tmp2[i] = 0;
@ -1752,7 +1751,7 @@ static void InitDialog(HWND hDlg)
} else { } else {
embedded_sl_version[i] = GetSyslinuxVersion(buf, len, &ext); embedded_sl_version[i] = GetSyslinuxVersion(buf, len, &ext);
static_sprintf(embedded_sl_version_str[i], "%d.%02d", SL_MAJOR(embedded_sl_version[i]), SL_MINOR(embedded_sl_version[i])); static_sprintf(embedded_sl_version_str[i], "%d.%02d", SL_MAJOR(embedded_sl_version[i]), SL_MINOR(embedded_sl_version[i]));
safe_strcpy(embedded_sl_version_ext[i], sizeof(embedded_sl_version_ext[i]), ext); static_strcpy(embedded_sl_version_ext[i], ext);
free(buf); free(buf);
} }
} }
@ -1972,7 +1971,7 @@ static void ShowLanguageMenu(RECT rcExclude)
static_sprintf(lang, LEFT_TO_RIGHT_EMBEDDING "(%s) " POP_DIRECTIONAL_FORMATTING "%s", r, l); static_sprintf(lang, LEFT_TO_RIGHT_EMBEDDING "(%s) " POP_DIRECTIONAL_FORMATTING "%s", r, l);
safe_free(str); safe_free(str);
} else { } else {
safe_strcpy(lang, sizeof(lang), lcmd->txt[1]); static_strcpy(lang, lcmd->txt[1]);
} }
InsertMenuU(menu, -1, MF_BYPOSITION|((selected_locale == lcmd)?MF_CHECKED:0), UM_LANGUAGE_MENU_MAX++, lang); InsertMenuU(menu, -1, MF_BYPOSITION|((selected_locale == lcmd)?MF_CHECKED:0), UM_LANGUAGE_MENU_MAX++, lang);
} }
@ -2047,7 +2046,7 @@ static void SaveVHD(void)
ULARGE_INTEGER free_space; ULARGE_INTEGER free_space;
if (DriveIndex >= 0) if (DriveIndex >= 0)
safe_sprintf(filename, sizeof(filename), "%s.vhd", DriveLabel.String[DriveIndex]); static_sprintf(filename, "%s.vhd", DriveLabel.String[DriveIndex]);
if ((DriveIndex != CB_ERR) && (!format_op_in_progress) && (format_thid == NULL)) { if ((DriveIndex != CB_ERR) && (!format_op_in_progress) && (format_thid == NULL)) {
img_save.Type = IMG_SAVE_TYPE_VHD; img_save.Type = IMG_SAVE_TYPE_VHD;
img_save.DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, DriveIndex); img_save.DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, DriveIndex);
@ -2075,7 +2074,7 @@ static void SaveVHD(void)
uprintf("\r\nSave to VHD operation started"); uprintf("\r\nSave to VHD operation started");
PrintInfo(0, -1); PrintInfo(0, -1);
timer = 0; timer = 0;
safe_sprintf(szTimer, sizeof(szTimer), "00:00:00"); static_sprintf(szTimer, "00:00:00");
SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer);
SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer);
} else { } else {
@ -2120,7 +2119,7 @@ static void SaveISO(void)
(img_save.BufSize > 8 * MB) && (img_save.DeviceSize <= img_save.BufSize * 64); (img_save.BufSize > 8 * MB) && (img_save.DeviceSize <= img_save.BufSize * 64);
img_save.BufSize /= 2); img_save.BufSize /= 2);
if ((img_save.Label != NULL) && (img_save.Label[0] != 0)) if ((img_save.Label != NULL) && (img_save.Label[0] != 0))
safe_sprintf(filename, sizeof(filename), "%s.iso", img_save.Label); static_sprintf(filename, "%s.iso", img_save.Label);
uprintf("ISO media size %s", SizeToHumanReadable(img_save.DeviceSize, FALSE, FALSE)); uprintf("ISO media size %s", SizeToHumanReadable(img_save.DeviceSize, FALSE, FALSE));
img_save.ImagePath = FileDialog(TRUE, NULL, &img_ext, 0); img_save.ImagePath = FileDialog(TRUE, NULL, &img_ext, 0);
@ -2141,7 +2140,7 @@ static void SaveISO(void)
uprintf("\r\nSave to ISO operation started"); uprintf("\r\nSave to ISO operation started");
PrintInfo(0, -1); PrintInfo(0, -1);
timer = 0; timer = 0;
safe_sprintf(szTimer, sizeof(szTimer), "00:00:00"); static_sprintf(szTimer, "00:00:00");
SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer);
SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer);
} else { } else {
@ -2612,7 +2611,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
uprintf("\r\nFormat operation started"); uprintf("\r\nFormat operation started");
PrintInfo(0, -1); PrintInfo(0, -1);
timer = 0; timer = 0;
safe_sprintf(szTimer, sizeof(szTimer), "00:00:00"); static_sprintf(szTimer, "00:00:00");
SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer);
SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer);
} }
@ -2645,7 +2644,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
if (format_thid != NULL) { if (format_thid != NULL) {
PrintInfo(0, -1); PrintInfo(0, -1);
timer = 0; timer = 0;
safe_sprintf(szTimer, sizeof(szTimer), "00:00:00"); static_sprintf(szTimer, "00:00:00");
SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer); SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer);
SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer); SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer);
} else { } else {
@ -3116,24 +3115,24 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
} }
if (GetSystemDirectoryU(system_dir, sizeof(system_dir)) == 0) { if (GetSystemDirectoryU(system_dir, sizeof(system_dir)) == 0) {
uprintf("Could not get system directory: %s", WindowsErrorString()); uprintf("Could not get system directory: %s", WindowsErrorString());
safe_strcpy(system_dir, sizeof(system_dir), "C:\\Windows\\System32"); static_strcpy(system_dir, "C:\\Windows\\System32");
} }
if (GetTempPathU(sizeof(temp_dir), temp_dir) == 0) { if (GetTempPathU(sizeof(temp_dir), temp_dir) == 0) {
uprintf("Could not get temp directory: %s", WindowsErrorString()); uprintf("Could not get temp directory: %s", WindowsErrorString());
safe_strcpy(temp_dir, sizeof(temp_dir), ".\\"); static_strcpy(temp_dir, ".\\");
} }
// Construct Sysnative ourselves as there is no GetSysnativeDirectory() call // Construct Sysnative ourselves as there is no GetSysnativeDirectory() call
// By default (64bit app running on 64 bit OS or 32 bit app running on 32 bit OS) // By default (64bit app running on 64 bit OS or 32 bit app running on 32 bit OS)
// Sysnative and System32 are the same // Sysnative and System32 are the same
safe_strcpy(sysnative_dir, sizeof(sysnative_dir), system_dir); static_strcpy(sysnative_dir, system_dir);
// But if the app is 32 bit and the OS is 64 bit, Sysnative must differ from System32 // But if the app is 32 bit and the OS is 64 bit, Sysnative must differ from System32
#if (!defined(_WIN64) && !defined(BUILD64)) #if (!defined(_WIN64) && !defined(BUILD64))
if (is_x64()) { if (is_x64()) {
if (GetSystemWindowsDirectoryU(sysnative_dir, sizeof(sysnative_dir)) == 0) { if (GetSystemWindowsDirectoryU(sysnative_dir, sizeof(sysnative_dir)) == 0) {
uprintf("Could not get Windows directory: %s", WindowsErrorString()); uprintf("Could not get Windows directory: %s", WindowsErrorString());
safe_strcpy(sysnative_dir, sizeof(sysnative_dir), "C:\\Windows"); static_strcpy(sysnative_dir, "C:\\Windows");
} }
safe_strcat(sysnative_dir, sizeof(sysnative_dir), "\\Sysnative"); static_strcat(sysnative_dir, "\\Sysnative");
} }
#endif #endif
@ -3181,7 +3180,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
loc_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_LC_RUFUS_LOC), _RT_RCDATA, "embedded.loc", &loc_size, FALSE); loc_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_LC_RUFUS_LOC), _RT_RCDATA, "embedded.loc", &loc_size, FALSE);
if ( (GetTempFileNameU(temp_dir, APPLICATION_NAME, 0, loc_file) == 0) || (loc_file[0] == 0) ) { if ( (GetTempFileNameU(temp_dir, APPLICATION_NAME, 0, loc_file) == 0) || (loc_file[0] == 0) ) {
// Last ditch effort to get a loc file - just extract it to the current directory // Last ditch effort to get a loc file - just extract it to the current directory
safe_strcpy(loc_file, sizeof(loc_file), rufus_loc); static_strcpy(loc_file, rufus_loc);
} }
hFile = CreateFileU(loc_file, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, hFile = CreateFileU(loc_file, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ,
@ -3194,7 +3193,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
uprintf("localization: extracted data to '%s'", loc_file); uprintf("localization: extracted data to '%s'", loc_file);
safe_closehandle(hFile); safe_closehandle(hFile);
} else { } else {
safe_sprintf(loc_file, sizeof(loc_file), "%s\\%s", app_dir, rufus_loc); static_sprintf(loc_file, "%s\\%s", app_dir, rufus_loc);
external_loc_file = TRUE; external_loc_file = TRUE;
uprintf("using external loc file '%s'", loc_file); uprintf("using external loc file '%s'", loc_file);
} }

View File

@ -95,8 +95,10 @@
#define safe_strcp(dst, dst_max, src, count) do {memcpy(dst, src, safe_min(count, dst_max)); \ #define safe_strcp(dst, dst_max, src, count) do {memcpy(dst, src, safe_min(count, dst_max)); \
((char*)dst)[safe_min(count, dst_max)-1] = 0;} while(0) ((char*)dst)[safe_min(count, dst_max)-1] = 0;} while(0)
#define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1) #define safe_strcpy(dst, dst_max, src) safe_strcp(dst, dst_max, src, safe_strlen(src)+1)
#define static_strcpy(dst, src) safe_strcpy(dst, sizeof(dst), src)
#define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, dst_max - safe_strlen(dst) - 1)) #define safe_strncat(dst, dst_max, src, count) strncat(dst, src, safe_min(count, dst_max - safe_strlen(dst) - 1))
#define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1) #define safe_strcat(dst, dst_max, src) safe_strncat(dst, dst_max, src, safe_strlen(src)+1)
#define static_strcat(dst, src) safe_strcat(dst, sizeof(dst), src)
#define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2)) #define safe_strcmp(str1, str2) strcmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
#define safe_strstr(str1, str2) strstr(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2)) #define safe_strstr(str1, str2) strstr(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))
#define safe_stricmp(str1, str2) _stricmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2)) #define safe_stricmp(str1, str2) _stricmp(((str1==NULL)?"<NULL>":str1), ((str2==NULL)?"<NULL>":str2))

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376 IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.16.1174" CAPTION "Rufus 2.17.1175"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0 FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -366,8 +366,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,16,1174,0 FILEVERSION 2,17,1175,0
PRODUCTVERSION 2,16,1174,0 PRODUCTVERSION 2,17,1175,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -384,13 +384,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.16.1174" VALUE "FileVersion", "2.17.1175"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.16.1174" VALUE "ProductVersion", "2.17.1175"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"

View File

@ -94,7 +94,7 @@ static __inline char* ReadIniKeyStr(const char* key) {
str[0] = 0; str[0] = 0;
val = get_token_data_file(key, ini_file); val = get_token_data_file(key, ini_file);
if (val != NULL) { if (val != NULL) {
safe_strcpy(str, sizeof(str), val); static_strcpy(str, val);
free(val); free(val);
} }
return str; return str;

View File

@ -68,7 +68,7 @@ const char* SptStrerr(int errcode)
static char scsi_err[64]; static char scsi_err[64];
if ((errcode > 0) && (errcode <= 0xff)) { if ((errcode > 0) && (errcode <= 0xff)) {
safe_sprintf(scsi_err, sizeof(scsi_err), "SCSI status: 0x%02X", (uint8_t)errcode); static_sprintf(scsi_err, "SCSI status: 0x%02X", (uint8_t)errcode);
return (const char*)scsi_err; return (const char*)scsi_err;
} }

View File

@ -235,7 +235,7 @@ void GetWindowsVersion(void)
BOOL ws; BOOL ws;
nWindowsVersion = WINDOWS_UNDEFINED; nWindowsVersion = WINDOWS_UNDEFINED;
safe_strcpy(WindowsVersionStr, sizeof(WindowsVersionStr), "Windows Undefined"); static_strcpy(WindowsVersionStr, "Windows Undefined");
memset(&vi, 0, sizeof(vi)); memset(&vi, 0, sizeof(vi));
vi.dwOSVersionInfoSize = sizeof(vi); vi.dwOSVersionInfoSize = sizeof(vi);
@ -329,9 +329,9 @@ void GetWindowsVersion(void)
GetRegistryKeyStr(REGKEY_HKLM, "Microsoft\\Windows NT\\CurrentVersion\\CurrentBuildNumber", build_number, sizeof(build_number)); GetRegistryKeyStr(REGKEY_HKLM, "Microsoft\\Windows NT\\CurrentVersion\\CurrentBuildNumber", build_number, sizeof(build_number));
if (build_number[0] != 0) { if (build_number[0] != 0) {
nWindowsBuildNumber = atoi(build_number); // Keep a global copy nWindowsBuildNumber = atoi(build_number); // Keep a global copy
safe_strcat(WindowsVersionStr, sizeof(WindowsVersionStr), " (Build "); static_strcat(WindowsVersionStr, " (Build ");
safe_strcat(WindowsVersionStr, sizeof(WindowsVersionStr), build_number); static_strcat(WindowsVersionStr, build_number);
safe_strcat(WindowsVersionStr, sizeof(WindowsVersionStr), ")"); static_strcat(WindowsVersionStr, ")");
} }
} }
@ -905,7 +905,7 @@ char* GetCurrentMUI(void)
(pfLCIDToLocaleName(GetUserDefaultUILanguage(), wmui_str, LOCALE_NAME_MAX_LENGTH, 0) > 0) ) { (pfLCIDToLocaleName(GetUserDefaultUILanguage(), wmui_str, LOCALE_NAME_MAX_LENGTH, 0) > 0) ) {
wchar_to_utf8_no_alloc(wmui_str, mui_str, LOCALE_NAME_MAX_LENGTH); wchar_to_utf8_no_alloc(wmui_str, mui_str, LOCALE_NAME_MAX_LENGTH);
} else { } else {
safe_strcpy(mui_str, LOCALE_NAME_MAX_LENGTH, "en-US"); static_strcpy(mui_str, "en-US");
} }
return mui_str; return mui_str;
} }

View File

@ -151,7 +151,7 @@ static char err_string[256] = {0};
error_code = GetLastError(); error_code = GetLastError();
safe_sprintf(err_string, sizeof(err_string), "[0x%08lX] ", error_code); static_sprintf(err_string, "[0x%08lX] ", error_code);
size = FormatMessageU(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, HRESULT_CODE(error_code), size = FormatMessageU(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, NULL, HRESULT_CODE(error_code),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &err_string[strlen(err_string)], MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &err_string[strlen(err_string)],
@ -159,10 +159,10 @@ static char err_string[256] = {0};
if (size == 0) { if (size == 0) {
format_error = GetLastError(); format_error = GetLastError();
if ((format_error) && (format_error != 0x13D)) // 0x13D, decode error, is returned for unknown codes if ((format_error) && (format_error != 0x13D)) // 0x13D, decode error, is returned for unknown codes
safe_sprintf(err_string, sizeof(err_string), static_sprintf(err_string, "Windows error code 0x%08lX (FormatMessage error code 0x%08lX)",
"Windows error code 0x%08lX (FormatMessage error code 0x%08lX)", error_code, format_error); error_code, format_error);
else else
safe_sprintf(err_string, sizeof(err_string), "Unknown error 0x%08lX", error_code); static_sprintf(err_string, "Unknown error 0x%08lX", error_code);
} }
SetLastError(error_code); // Make sure we don't change the errorcode on exit SetLastError(error_code); // Make sure we don't change the errorcode on exit

View File

@ -202,7 +202,7 @@ void BrowseForFolder(void) {
if (tmp_path == NULL) { if (tmp_path == NULL) {
uprintf("Could not convert path\n"); uprintf("Could not convert path\n");
} else { } else {
safe_strcpy(szFolderPath, MAX_PATH, tmp_path); static_strcpy(szFolderPath, tmp_path);
safe_free(tmp_path); safe_free(tmp_path);
} }
} else { } else {
@ -630,7 +630,7 @@ INT_PTR CALLBACK AboutCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lP
CenterDialog(hDlg); CenterDialog(hDlg);
if (settings_commcheck) if (settings_commcheck)
ShowWindow(GetDlgItem(hDlg, IDC_ABOUT_UPDATES), SW_SHOW); ShowWindow(GetDlgItem(hDlg, IDC_ABOUT_UPDATES), SW_SHOW);
safe_sprintf(about_blurb, sizeof(about_blurb), about_blurb_format, lmprintf(MSG_174|MSG_RTF), static_sprintf(about_blurb, about_blurb_format, lmprintf(MSG_174|MSG_RTF),
lmprintf(MSG_175|MSG_RTF, rufus_version[0], rufus_version[1], rufus_version[2]), lmprintf(MSG_175|MSG_RTF, rufus_version[0], rufus_version[1], rufus_version[2]),
right_to_left_mode?"Akeo \\\\ Pete Batard 2011-2017 © Copyright":"Copyright © 2011-2017 Pete Batard / Akeo", right_to_left_mode?"Akeo \\\\ Pete Batard 2011-2017 © Copyright":"Copyright © 2011-2017 Pete Batard / Akeo",
lmprintf(MSG_176|MSG_RTF), lmprintf(MSG_177|MSG_RTF), lmprintf(MSG_178|MSG_RTF)); lmprintf(MSG_176|MSG_RTF), lmprintf(MSG_177|MSG_RTF), lmprintf(MSG_178|MSG_RTF));
@ -1459,7 +1459,7 @@ INT_PTR CALLBACK UpdateCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM l
IGNORE_RETVAL(ComboBox_SetCurSel(hBeta, ReadSettingBool(SETTING_INCLUDE_BETAS)?0:1)); IGNORE_RETVAL(ComboBox_SetCurSel(hBeta, ReadSettingBool(SETTING_INCLUDE_BETAS)?0:1));
hPolicy = GetDlgItem(hDlg, IDC_POLICY); hPolicy = GetDlgItem(hDlg, IDC_POLICY);
SendMessage(hPolicy, EM_AUTOURLDETECT, 1, 0); SendMessage(hPolicy, EM_AUTOURLDETECT, 1, 0);
safe_sprintf(update_policy_text, sizeof(update_policy_text), update_policy, lmprintf(MSG_179|MSG_RTF), static_sprintf(update_policy_text, update_policy, lmprintf(MSG_179|MSG_RTF),
lmprintf(MSG_180|MSG_RTF), lmprintf(MSG_181|MSG_RTF), lmprintf(MSG_182|MSG_RTF), lmprintf(MSG_183|MSG_RTF), lmprintf(MSG_180|MSG_RTF), lmprintf(MSG_181|MSG_RTF), lmprintf(MSG_182|MSG_RTF), lmprintf(MSG_183|MSG_RTF),
lmprintf(MSG_184|MSG_RTF), lmprintf(MSG_185|MSG_RTF), lmprintf(MSG_186|MSG_RTF)); lmprintf(MSG_184|MSG_RTF), lmprintf(MSG_185|MSG_RTF), lmprintf(MSG_186|MSG_RTF));
SendMessageA(hPolicy, EM_SETTEXTEX, (WPARAM)&friggin_microsoft_unicode_amateurs, (LPARAM)update_policy_text); SendMessageA(hPolicy, EM_SETTEXTEX, (WPARAM)&friggin_microsoft_unicode_amateurs, (LPARAM)update_policy_text);

View File

@ -110,7 +110,7 @@ static BOOL Get7ZipPath(void)
{ {
if ( (GetRegistryKeyStr(REGKEY_HKCU, "7-Zip\\Path", sevenzip_path, sizeof(sevenzip_path))) if ( (GetRegistryKeyStr(REGKEY_HKCU, "7-Zip\\Path", sevenzip_path, sizeof(sevenzip_path)))
|| (GetRegistryKeyStr(REGKEY_HKLM, "7-Zip\\Path", sevenzip_path, sizeof(sevenzip_path))) ) { || (GetRegistryKeyStr(REGKEY_HKLM, "7-Zip\\Path", sevenzip_path, sizeof(sevenzip_path))) ) {
safe_strcat(sevenzip_path, sizeof(sevenzip_path), "\\7z.exe"); static_strcat(sevenzip_path, "\\7z.exe");
return (_access(sevenzip_path, 0) != -1); return (_access(sevenzip_path, 0) != -1);
} }
return FALSE; return FALSE;
@ -471,11 +471,11 @@ BOOL WimExtractFile_7z(const char* image, int index, const char* src, const char
// return an error code if it can't extract the file), we need // return an error code if it can't extract the file), we need
// to issue 2 passes. See github issue #680. // to issue 2 passes. See github issue #680.
for (n = 0; n < 2; n++) { for (n = 0; n < 2; n++) {
safe_strcpy(tmpdst, sizeof(tmpdst), dst); static_strcpy(tmpdst, dst);
for (i = strlen(tmpdst) - 1; (i > 0) && (tmpdst[i] != '\\') && (tmpdst[i] != '/'); i--); for (i = strlen(tmpdst) - 1; (i > 0) && (tmpdst[i] != '\\') && (tmpdst[i] != '/'); i--);
tmpdst[i] = 0; tmpdst[i] = 0;
safe_sprintf(cmdline, sizeof(cmdline), "\"%s\" -y e \"%s\" %s%s", sevenzip_path, static_sprintf(cmdline, "\"%s\" -y e \"%s\" %s%s", sevenzip_path,
image, (n == 0) ? index_prefix : "", src); image, (n == 0) ? index_prefix : "", src);
if (RunCommand(cmdline, tmpdst, FALSE) != 0) { if (RunCommand(cmdline, tmpdst, FALSE) != 0) {
uprintf(" Could not launch 7z.exe: %s", WindowsErrorString()); uprintf(" Could not launch 7z.exe: %s", WindowsErrorString());
@ -484,8 +484,8 @@ BOOL WimExtractFile_7z(const char* image, int index, const char* src, const char
for (i = safe_strlen(src); (i > 0) && (src[i] != '\\') && (src[i] != '/'); i--); for (i = safe_strlen(src); (i > 0) && (src[i] != '\\') && (src[i] != '/'); i--);
if (i == 0) if (i == 0)
safe_strcat(tmpdst, sizeof(tmpdst), "\\"); static_strcat(tmpdst, "\\");
safe_strcat(tmpdst, sizeof(tmpdst), &src[i]); static_strcat(tmpdst, &src[i]);
if (_access(tmpdst, 0) == 0) if (_access(tmpdst, 0) == 0)
// File was extracted => move on // File was extracted => move on
break; break;