Skip to content

Commit

Permalink
[misc] add static_strcat & static_strcpy and use static_ calls wherev…
Browse files Browse the repository at this point in the history
…er possible

* Also set Rufus next to 2.17 and fix a warning
  • Loading branch information
pbatard committed Aug 10, 2017
1 parent 5d37108 commit 90dc847
Show file tree
Hide file tree
Showing 23 changed files with 121 additions and 120 deletions.
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# 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>.
#
Expand Down Expand Up @@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='rufus'
PACKAGE_TARNAME='rufus'
PACKAGE_VERSION='2.16'
PACKAGE_STRING='rufus 2.16'
PACKAGE_VERSION='2.17'
PACKAGE_STRING='rufus 2.17'
PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues'
PACKAGE_URL='https://rufus.akeo.ie'

Expand Down Expand Up @@ -1228,7 +1228,7 @@ if test "$ac_init_help" = "long"; then
# 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.
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]...
Expand Down Expand Up @@ -1294,7 +1294,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of rufus 2.16:";;
short | recursive ) echo "Configuration of rufus 2.17:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1385,7 +1385,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
rufus configure 2.16
rufus configure 2.17
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1440,7 +1440,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
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
$ $0 $@
Expand Down Expand Up @@ -2303,7 +2303,7 @@ fi
# Define the identity of the package.
PACKAGE='rufus'
VERSION='2.16'
VERSION='2.17'
cat >>confdefs.h <<_ACEOF
Expand Down Expand Up @@ -4483,7 +4483,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
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
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -4537,7 +4537,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
rufus config.status 2.16
rufus config.status 2.17
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -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])
AC_CONFIG_SRCDIR([src/rufus.c])
AC_CONFIG_MACRO_DIR([m4])
Expand Down
2 changes: 1 addition & 1 deletion res/appstore/AppxManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
for an interesting struggle, when you also happen to have a comma in one of the fields... -->
<Identity
Name="Rufus"
Version="2.16.1170.0"
Version="2.17.1170.0"
ProcessorArchitecture="x86"
Publisher='CN=Akeo Consulting, O=Akeo Consulting, STREET="24, Grey Rock", L=Milford, S=Co Donegal, PostalCode=Co Donegal, C=IE' />
<Properties>
Expand Down
2 changes: 1 addition & 1 deletion res/appstore/packme.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@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 current directory will be included, including any previous .appx, which makes for nice recursion...
Expand Down
16 changes: 8 additions & 8 deletions src/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ BOOL GetOpticalMedia(IMG_SAVE* img_save)
if (!SetupDiGetDeviceRegistryPropertyU(dev_info, &dev_info_data, SPDRP_FRIENDLYNAME,
&datatype, (LPBYTE)str, sizeof(str), &size)) {
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);
devint_data.cbSize = sizeof(devint_data);
Expand Down Expand Up @@ -245,7 +245,7 @@ BOOL GetOpticalMedia(IMG_SAVE* img_save)
label[k] = 0;
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->DeviceSize = DiskGeometry->DiskSize.QuadPart;
safe_closehandle(hDrive);
Expand Down Expand Up @@ -507,7 +507,7 @@ BOOL GetDevices(DWORD devnum)
&datatype, (LPBYTE)buffer, sizeof(buffer), &size)) {
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)"
safe_strcpy(buffer, sizeof(buffer), lmprintf(MSG_045));
static_strcpy(buffer, lmprintf(MSG_045));
} else if ((!props.is_VHD) && (devid_list != NULL)) {
// 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...
Expand Down Expand Up @@ -580,7 +580,7 @@ BOOL GetDevices(DWORD devnum)
#ifdef FORCED_DEVICE
props.vid = FORCED_VID;
props.pid = FORCED_PID;
safe_strcpy(buffer, sizeof(buffer), FORCED_NAME);
static_strcpy(buffer, FORCED_NAME);
#endif
}
break;
Expand All @@ -605,7 +605,7 @@ BOOL GetDevices(DWORD devnum)
uuprintf("Found non-USB non-removable device '%s' => Eliminated", buffer);
continue;
}
safe_strcpy(str, sizeof(str), "????:????"); // Couldn't figure VID:PID
static_strcpy(str, "????:????"); // Couldn't figure VID:PID
} else {
static_sprintf(str, "%04X:%04X", props.vid, props.pid);
}
Expand Down Expand Up @@ -731,14 +731,14 @@ BOOL GetDevices(DWORD devnum)
}
// We have multiple volumes assigned to the same device (multiple partitions)
// 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));
for (k=0, remove_drive=0; drive_letters[k] && (!remove_drive); k++) {
// Append all the drive letters we detected
letter_name[2] = drive_letters[k];
if (right_to_left_mode)
safe_strcat(entry_msg, sizeof(entry_msg), RIGHT_TO_LEFT_MARK);
safe_strcat(entry_msg, sizeof(entry_msg), letter_name);
static_strcat(entry_msg, RIGHT_TO_LEFT_MARK);
static_strcat(entry_msg, letter_name);
if (drive_letters[k] == (PathGetDriveNumberU(app_dir) + 'A'))
remove_drive = 1;
if (drive_letters[k] == (PathGetDriveNumberU(system_dir) + 'A'))
Expand Down
14 changes: 7 additions & 7 deletions src/dos.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,16 @@ static BOOL ExtractMSDOS(const char* path)
return FALSE;

// Reduce the visible mess by placing all the locale files into a subdir
safe_strcpy(locale_path, sizeof(locale_path), path);
safe_strcat(locale_path, sizeof(locale_path), "LOCALE\\");
static_strcpy(locale_path, path);
static_strcat(locale_path, "LOCALE\\");
CreateDirectoryA(locale_path, NULL);

len = GetSystemDirectoryA(dllname, sizeof(dllname));
if ((len == 0) || (len >= sizeof(dllname))) {
uprintf("Unable to get system directory: %s\n", WindowsErrorString());
goto out;
}
safe_strcat(dllname, sizeof(dllname), "\\diskcopy.dll");
static_strcat(dllname, "\\diskcopy.dll");
hDLL = LoadLibraryA(dllname);
if (hDLL == NULL) {
uprintf("Unable to open %s: %s\n", dllname, WindowsErrorString());
Expand Down Expand Up @@ -375,15 +375,15 @@ BOOL ExtractFreeDOS(const char* path)
}

// Reduce the visible mess by placing all the locale files into a subdir
safe_strcpy(locale_path, sizeof(locale_path), path);
safe_strcat(locale_path, sizeof(locale_path), "LOCALE\\");
static_strcpy(locale_path, path);
static_strcat(locale_path, "LOCALE\\");
CreateDirectoryA(locale_path, NULL);

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);

safe_strcpy(filename, sizeof(filename), ((i<2)?path:locale_path));
safe_strcat(filename, sizeof(filename), res_name[i]);
static_strcpy(filename, ((i<2)?path:locale_path));
static_strcat(filename, res_name[i]);

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);
Expand Down
12 changes: 6 additions & 6 deletions src/dos_locale.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,8 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)

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

// CONFIG.SYS
safe_strcpy(filename, sizeof(filename), path);
safe_strcat(filename, sizeof(filename), "\\CONFIG.SYS");
static_strcpy(filename, path);
static_strcat(filename, "\\CONFIG.SYS");
fd = fopen(filename, "w+");
if (fd == NULL) {
uprintf("Unable to create 'CONFIG.SYS': %s.\n", WindowsErrorString());
Expand All @@ -1033,8 +1033,8 @@ BOOL SetDOSLocale(const char* path, BOOL bFreeDOS)
uprintf("Successfully wrote 'CONFIG.SYS'\n");

// AUTOEXEC.BAT
safe_strcpy(filename, sizeof(filename), path);
safe_strcat(filename, sizeof(filename), "\\AUTOEXEC.BAT");
static_strcpy(filename, path);
static_strcat(filename, "\\AUTOEXEC.BAT");
fd = fopen(filename, "w+");
if (fd == NULL) {
uprintf("Unable to create 'AUTOEXEC.BAT': %s.\n", WindowsErrorString());
Expand Down
6 changes: 3 additions & 3 deletions src/drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ char* GetPhysicalName(DWORD DriveIndex)
char physical_name[24];

CheckDriveIndex(DriveIndex);
safe_sprintf(physical_name, sizeof(physical_name), "\\\\.\\PHYSICALDRIVE%lu", DriveIndex);
static_sprintf(physical_name, "\\\\.\\PHYSICALDRIVE%lu", DriveIndex);
success = TRUE;
out:
return (success)?safe_strdup(physical_name):NULL;
Expand Down Expand Up @@ -444,7 +444,7 @@ static BOOL _GetDriveLettersAndType(DWORD DriveIndex, char* drive_letters, UINT*
if ((_drive_type != DRIVE_REMOVABLE) && (_drive_type != DRIVE_FIXED))
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,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hDrive == INVALID_HANDLE_VALUE) {
Expand Down Expand Up @@ -552,7 +552,7 @@ BOOL GetDriveLabel(DWORD DriveIndex, char* letters, char** label)
safe_closehandle(hPhysical);
if (AutorunLabel != NULL) {
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);
*label = VolumeLabel;
} else if (GetVolumeInformationU(DrivePath, VolumeLabel, ARRAYSIZE(VolumeLabel),
Expand Down
24 changes: 12 additions & 12 deletions src/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,8 @@ static BOOL FormatDrive(DWORD DriveIndex)

// Check if Windows picked the UEFI:NTFS partition
// NB: No need to do this for Large FAT32, as this only applies to NTFS
safe_strcpy(path, MAX_PATH, VolumeName);
safe_strcat(path, MAX_PATH, "EFI\\Rufus\\ntfs_x64.efi");
static_strcpy(path, VolumeName);
static_strcat(path, "EFI\\Rufus\\ntfs_x64.efi");
if (PathFileExistsA(path)) {
uprintf("Windows selected the UEFI:NTFS partition for formatting - Retry needed", VolumeName);
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_RETRY;
Expand Down Expand Up @@ -1167,16 +1167,16 @@ static BOOL SetupWinPE(char drive_letter)

index = ((img_report.winpe&WINPE_I386) == WINPE_I386)?0:1;
// Allow other values than harddisk 1, as per user choice for disk ID
safe_sprintf(setupsrcdev, sizeof(setupsrcdev),
"SetupSourceDevice = \"\\device\\harddisk%d\\partition1\"", ComboBox_GetCurSel(hDiskID));
static_sprintf(setupsrcdev, "SetupSourceDevice = \"\\device\\harddisk%d\\partition1\"",
ComboBox_GetCurSel(hDiskID));
// Copy of ntdetect.com in root
safe_sprintf(src, sizeof(src), "%c:\\%s\\ntdetect.com", drive_letter, basedir[index]);
safe_sprintf(dst, sizeof(dst), "%c:\\ntdetect.com", drive_letter);
static_sprintf(src, "%c:\\%s\\ntdetect.com", drive_letter, basedir[index]);
static_sprintf(dst, "%c:\\ntdetect.com", drive_letter);
CopyFileA(src, dst, TRUE);
if (!img_report.uses_minint) {
// 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]);
safe_sprintf(dst, sizeof(dst), "%c:\\txtsetup.sif", drive_letter);
static_sprintf(src, "%c:\\%s\\txtsetup.sif", drive_letter, basedir[index]);
static_sprintf(dst, "%c:\\txtsetup.sif", drive_letter);
if (!CopyFileA(src, dst, TRUE)) {
uprintf("Did not copy %s as %s: %s\n", src, dst, WindowsErrorString());
}
Expand All @@ -1187,8 +1187,8 @@ static BOOL SetupWinPE(char drive_letter)
uprintf("Successfully added '%s' to %s\n", setupsrcdev, dst);
}

safe_sprintf(src, sizeof(src), "%c:\\%s\\setupldr.bin", drive_letter, basedir[index]);
safe_sprintf(dst, sizeof(dst), "%c:\\BOOTMGR", drive_letter);
static_sprintf(src, "%c:\\%s\\setupldr.bin", drive_letter, basedir[index]);
static_sprintf(dst, "%c:\\BOOTMGR", drive_letter);
if (!CopyFileA(src, dst, TRUE)) {
uprintf("Did not copy %s as %s: %s\n", src, dst, WindowsErrorString());
}
Expand Down Expand Up @@ -1309,7 +1309,7 @@ int SetWinToGoIndex(void)
|| (GetTempFileNameU(tmp_path, APPLICATION_NAME, 0, xml_file) == 0)
|| (xml_file[0] == 0)) {
// 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
DeleteFileU(xml_file);
Expand Down Expand Up @@ -1771,7 +1771,7 @@ DWORD WINAPI FormatThread(void* param)
// create a log file for bad blocks report. Since %USERPROFILE% may
// have localized characters, we use the UTF-8 API.
userdir = getenvU("USERPROFILE");
safe_strcpy(logfile, MAX_PATH, userdir);
static_strcpy(logfile, userdir);
safe_free(userdir);
GetLocalTime(&lt);
safe_sprintf(&logfile[strlen(logfile)], sizeof(logfile)-strlen(logfile)-1,
Expand Down
2 changes: 1 addition & 1 deletion src/icon.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ BOOL SetAutorun(const char* path)
char filename[64];
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
if (fd != NULL) {
uprintf("%s already exists - keeping it", filename);
Expand Down
Loading

0 comments on commit 90dc847

Please sign in to comment.