Fix more potential buffer overflows in paths #92

This commit is contained in:
Dimitris Panokostas 2017-04-21 22:27:47 +02:00
parent 91e2dac3d9
commit a853165ca8
16 changed files with 128 additions and 128 deletions

View file

@ -3968,7 +3968,7 @@ void cfgfile_backup(const TCHAR *path)
{
TCHAR dpath[MAX_DPATH];
fetch_configurationpath(dpath, sizeof(dpath) / sizeof(TCHAR));
fetch_configurationpath(dpath, sizeof dpath / sizeof(TCHAR));
_tcscat(dpath, _T("configuration.backup"));
//bool hidden = my_isfilehidden(dpath);
my_unlink(dpath);

View file

@ -385,7 +385,7 @@ static void fixcharset (TCHAR *s)
char tmp[MAX_DPATH];
if (!s)
return;
ua_fs_copy (tmp, MAX_DPATH, s, '_');
ua_fs_copy (tmp, sizeof tmp, s, '_');
au_fs_copy (s, strlen (tmp) + 1, tmp);
}

View file

@ -131,27 +131,27 @@ extern void restore_bootrom (int, size_t);
extern void restore_pram (int, size_t);
extern void restore_ram (size_t, uae_u8*);
extern uae_u8 *save_cram(int *);
extern uae_u8 *save_bram(int *);
extern uae_u8 *save_fram(int *);
extern uae_u8 *save_zram(int *, int);
extern uae_u8 *save_bootrom(int *);
extern uae_u8 *save_pram(int *);
extern uae_u8 *save_a3000lram(int *);
extern uae_u8 *save_a3000hram(int *);
extern uae_u8 *restore_rom(uae_u8 *);
extern uae_u8 *save_rom(int, int *, uae_u8 *);
extern uae_u8 *restore_action_replay(uae_u8 *);
extern uae_u8 *save_action_replay(int *, uae_u8 *);
extern uae_u8 *restore_hrtmon(uae_u8 *);
extern uae_u8 *save_cram(int *);
extern uae_u8 *save_bram(int *);
extern uae_u8 *save_fram(int *);
extern uae_u8 *save_zram(int *, int);
extern uae_u8 *save_bootrom(int *);
extern uae_u8 *save_pram(int *);
extern uae_u8 *save_a3000lram(int *);
extern uae_u8 *save_a3000hram(int *);
extern uae_u8 *restore_rom(uae_u8 *);
extern uae_u8 *save_rom(int, int *, uae_u8 *);
extern uae_u8 *restore_action_replay(uae_u8 *);
extern uae_u8 *save_action_replay(int *, uae_u8 *);
extern uae_u8 *restore_hrtmon(uae_u8 *);
extern uae_u8 *save_hrtmon(int *, uae_u8 *);
extern void savestate_initsave(const TCHAR *filename, int docompress, int nodialogs, bool save);
extern int save_state(const TCHAR *filename, const TCHAR *description);
extern void restore_state(const TCHAR *filename);
extern void savestate_restore_finish(void);
extern void savestate_initsave(const TCHAR *filename, int docompress, int nodialogs, bool save);
extern int save_state(const TCHAR *filename, const TCHAR *description);
extern void restore_state(const TCHAR *filename);
extern void savestate_restore_finish(void);
extern void savestate_memorysave(void);
extern void custom_save_state (void);
@ -170,18 +170,18 @@ extern int savestate_state;
extern TCHAR savestate_fname[MAX_DPATH];
extern struct zfile *savestate_file;
STATIC_INLINE bool isrestore(void)
{
return savestate_state == STATE_RESTORE || savestate_state == STATE_REWIND;
STATIC_INLINE bool isrestore(void)
{
return savestate_state == STATE_RESTORE || savestate_state == STATE_REWIND;
}
extern void savestate_quick(int slot, int save);
extern void savestate_capture(int);
extern void savestate_free(void);
extern void savestate_init(void);
extern void savestate_rewind(void);
extern int savestate_dorewind(int);
extern void savestate_listrewind(void);
extern void statefile_save_recording(const TCHAR*);
extern void savestate_quick(int slot, int save);
extern void savestate_capture(int);
extern void savestate_free(void);
extern void savestate_init(void);
extern void savestate_rewind(void);
extern int savestate_dorewind(int);
extern void savestate_listrewind(void);
extern void statefile_save_recording(const TCHAR*);
extern void savestate_capture_request(void);

View file

@ -355,7 +355,7 @@ void fetch_configurationpath(char* out, int size)
void set_configurationpath(char* newpath)
{
strncpy(config_path, newpath, MAX_DPATH);
strncpy(config_path, newpath, sizeof config_path);
}
void fetch_rompath(char* out, int size)
@ -365,7 +365,7 @@ void fetch_rompath(char* out, int size)
void set_rompath(char* newpath)
{
strncpy(rom_path, newpath, MAX_DPATH);
strncpy(rom_path, newpath, sizeof rom_path);
}
void fetch_rp9path(char* out, int size)
@ -536,46 +536,46 @@ void saveAdfDir()
char path[MAX_DPATH];
int i;
snprintf(path, MAX_DPATH, "%s/conf/adfdir.conf", start_path_data);
snprintf(path, sizeof path, "%s/conf/adfdir.conf", start_path_data);
FILE* f = fopen(path, "w");
if (!f)
return;
char buffer[MAX_DPATH];
snprintf(buffer, MAX_DPATH, "path=%s\n", currentDir);
snprintf(buffer, sizeof buffer, "path=%s\n", currentDir);
fputs(buffer, f);
snprintf(buffer, MAX_DPATH, "config_path=%s\n", config_path);
snprintf(buffer, sizeof buffer, "config_path=%s\n", config_path);
fputs(buffer, f);
snprintf(buffer, MAX_DPATH, "rom_path=%s\n", rom_path);
snprintf(buffer, sizeof buffer, "rom_path=%s\n", rom_path);
fputs(buffer, f);
snprintf(buffer, MAX_DPATH, "ROMs=%d\n", lstAvailableROMs.size());
snprintf(buffer, sizeof buffer, "ROMs=%d\n", lstAvailableROMs.size());
fputs(buffer, f);
for (i = 0; i < lstAvailableROMs.size(); ++i)
{
snprintf(buffer, MAX_DPATH, "ROMName=%s\n", lstAvailableROMs[i]->Name);
snprintf(buffer, sizeof buffer, "ROMName=%s\n", lstAvailableROMs[i]->Name);
fputs(buffer, f);
snprintf(buffer, MAX_DPATH, "ROMPath=%s\n", lstAvailableROMs[i]->Path);
snprintf(buffer, sizeof buffer, "ROMPath=%s\n", lstAvailableROMs[i]->Path);
fputs(buffer, f);
snprintf(buffer, MAX_DPATH, "ROMType=%d\n", lstAvailableROMs[i]->ROMType);
snprintf(buffer, sizeof buffer, "ROMType=%d\n", lstAvailableROMs[i]->ROMType);
fputs(buffer, f);
}
snprintf(buffer, MAX_DPATH, "MRUDiskList=%d\n", lstMRUDiskList.size());
snprintf(buffer, sizeof buffer, "MRUDiskList=%d\n", lstMRUDiskList.size());
fputs(buffer, f);
for (i = 0; i < lstMRUDiskList.size(); ++i)
{
snprintf(buffer, MAX_DPATH, "Diskfile=%s\n", lstMRUDiskList[i].c_str());
snprintf(buffer, sizeof buffer, "Diskfile=%s\n", lstMRUDiskList[i].c_str());
fputs(buffer, f);
}
snprintf(buffer, MAX_DPATH, "MRUCDList=%d\n", lstMRUCDList.size());
snprintf(buffer, sizeof buffer, "MRUCDList=%d\n", lstMRUCDList.size());
fputs(buffer, f);
for (i = 0; i < lstMRUCDList.size(); ++i)
{
snprintf(buffer, MAX_DPATH, "CDfile=%s\n", lstMRUCDList[i].c_str());
snprintf(buffer, sizeof buffer, "CDfile=%s\n", lstMRUCDList[i].c_str());
fputs(buffer, f);
}
@ -585,7 +585,7 @@ void saveAdfDir()
void get_string(FILE* f, char* dst, int size)
{
char buffer[MAX_PATH];
fgets(buffer, MAX_PATH, f);
fgets(buffer, sizeof buffer, f);
int i = strlen(buffer);
while (i > 0 && (buffer[i - 1] == '\t' || buffer[i - 1] == ' '
|| buffer[i - 1] == '\r' || buffer[i - 1] == '\n'))
@ -599,11 +599,11 @@ void loadAdfDir()
int i;
strcpy(currentDir, start_path_data);
snprintf(config_path, MAX_DPATH, "%s/conf/", start_path_data);
snprintf(rom_path, MAX_DPATH, "%s/kickstarts/", start_path_data);
snprintf(rp9_path, MAX_DPATH, "%s/rp9/", start_path_data);
snprintf(config_path, sizeof config_path, "%s/conf/", start_path_data);
snprintf(rom_path, sizeof rom_path, "%s/kickstarts/", start_path_data);
snprintf(rp9_path, sizeof rp9_path, "%s/rp9/", start_path_data);
snprintf(path, MAX_DPATH, "%s/conf/adfdir.conf", start_path_data);
snprintf(path, sizeof path, "%s/conf/adfdir.conf", start_path_data);
FILE* f1 = fopen(path, "rt");
if (f1)
{
@ -637,7 +637,7 @@ void loadAdfDir()
for (i = 0; i < numDisks; ++i)
{
fscanf(f1, "Diskfile=");
get_string(f1, disk, sizeof(disk));
get_string(f1, disk, sizeof disk);
FILE * f = fopen(disk, "rb");
if (f != NULL)
{
@ -653,7 +653,7 @@ void loadAdfDir()
for (i = 0; i < numCD; ++i)
{
fscanf(f1, "CDfile=");
get_string(f1, cd, sizeof(cd));
get_string(f1, cd, sizeof cd);
FILE * f = fopen(cd, "rb");
if (f != NULL)
{
@ -698,11 +698,11 @@ int main(int argc, char* argv[])
max_uae_height = 1080;
// Get startup path
getcwd(start_path_data, MAX_DPATH);
getcwd(start_path_data, sizeof start_path_data);
loadAdfDir();
rp9_init();
snprintf(savestate_fname, MAX_DPATH, "%s/saves/default.ads", start_path_data);
snprintf(savestate_fname, sizeof savestate_fname, "%s/saves/default.ads", start_path_data);
logging_init();
memset(&action, 0, sizeof(action));

View file

@ -31,7 +31,7 @@ struct MultiDisplay Displays[MAX_DISPLAYS];
int screen_is_picasso = 0;
static SDL_Surface* current_screenshot = nullptr;
static char screenshot_filename_default[MAX_PATH] =
static char screenshot_filename_default[MAX_DPATH] =
{
'/', 't', 'm', 'p', '/', 'n', 'u', 'l', 'l', '.', 'p', 'n', 'g', '\0'
};

View file

@ -124,12 +124,12 @@ void ClearAvailableROMList()
static void addrom(struct romdata* rd, const char* path)
{
AvailableROM* tmp;
char tmpName[MAX_DPATH];
char tmpName[MAX_PATH];
tmp = new AvailableROM();
getromname(rd, tmpName);
strncpy(tmp->Name, tmpName, MAX_PATH);
strncpy(tmp->Name, tmpName, sizeof tmp->Name);
if (path != nullptr)
strncpy(tmp->Path, path, MAX_PATH);
strncpy(tmp->Path, path, sizeof tmp->Path);
tmp->ROMType = rd->type;
lstAvailableROMs.push_back(tmp);
romlist_add(path, rd);
@ -270,20 +270,20 @@ static void scan_rom(char* path)
void RescanROMs()
{
vector<string> files;
char path[MAX_DPATH];
char path[MAX_PATH];
romlist_clear();
ClearAvailableROMList();
fetch_rompath(path, MAX_DPATH);
fetch_rompath(path, sizeof path);
load_keyring(&changed_prefs, path);
ReadDirectory(path, nullptr, &files);
for (int i = 0; i < files.size(); ++i)
{
char tmppath[MAX_PATH];
strncpy(tmppath, path, MAX_DPATH);
strncat(tmppath, files[i].c_str(), MAX_DPATH);
strncpy(tmppath, path, sizeof tmppath);
strncat(tmppath, files[i].c_str(), sizeof tmppath);
scan_rom(tmppath);
}
@ -312,7 +312,7 @@ static void ClearConfigFileList()
void ReadConfigFileList()
{
char path[MAX_PATH];
char path[MAX_DPATH];
vector<string> files;
const char* filter_rp9[] = {".rp9", "\0"};
const char* filter_uae[] = {".uae", "\0"};
@ -345,15 +345,15 @@ void ReadConfigFileList()
ConfigFilesList.push_back(buildin);
// Read rp9 files
fetch_rp9path(path, MAX_PATH);
fetch_rp9path(path, sizeof path);
ReadDirectory(path, nullptr, &files);
FilterFiles(&files, filter_rp9);
for (int i = 0; i < files.size(); ++i)
{
ConfigFileInfo* tmp = new ConfigFileInfo();
strncpy(tmp->FullPath, path, MAX_DPATH);
strncpy(tmp->FullPath, path, sizeof tmp->FullPath);
strcat(tmp->FullPath, files[i].c_str());
strncpy(tmp->Name, files[i].c_str(), MAX_DPATH);
strncpy(tmp->Name, files[i].c_str(), sizeof tmp->Name);
removeFileExtension(tmp->Name);
strcpy(tmp->Description, _T("rp9"));
tmp->BuiltInID = BUILTINID_NONE;
@ -361,15 +361,15 @@ void ReadConfigFileList()
}
// Read standard config files
fetch_configurationpath(path, MAX_PATH);
fetch_configurationpath(path, sizeof path);
ReadDirectory(path, nullptr, &files);
FilterFiles(&files, filter_uae);
for (int i = 0; i < files.size(); ++i)
{
ConfigFileInfo* tmp = new ConfigFileInfo();
strncpy(tmp->FullPath, path, MAX_DPATH);
strncpy(tmp->FullPath, path, sizeof tmp->FullPath);
strcat(tmp->FullPath, files[i].c_str());
strncpy(tmp->Name, files[i].c_str(), MAX_DPATH);
strncpy(tmp->Name, files[i].c_str(), sizeof tmp->Name);
removeFileExtension(tmp->Name);
cfgfile_get_description(tmp->FullPath, tmp->Description, nullptr, nullptr, nullptr);
tmp->BuiltInID = BUILTINID_NONE;
@ -384,9 +384,9 @@ void ReadConfigFileList()
if (strcmp(files[i].c_str(), "adfdir.conf"))
{
ConfigFileInfo* tmp = new ConfigFileInfo();
strncpy(tmp->FullPath, path, MAX_DPATH);
strncpy(tmp->FullPath, path, sizeof tmp->FullPath);
strcat(tmp->FullPath, files[i].c_str());
strncpy(tmp->Name, files[i].c_str(), MAX_DPATH);
strncpy(tmp->Name, files[i].c_str(), sizeof tmp->Name);
removeFileExtension(tmp->Name);
strcpy(tmp->Description, "Old style configuration file");
tmp->BuiltInID = BUILTINID_NONE;
@ -410,7 +410,7 @@ ConfigFileInfo* SearchConfigInList(const char* name)
{
for (int i = 0; i < ConfigFilesList.size(); ++i)
{
if (!strncasecmp(ConfigFilesList[i]->Name, name, MAX_DPATH))
if (!strncasecmp(ConfigFilesList[i]->Name, name, sizeof ConfigFilesList[i]->Name))
return ConfigFilesList[i];
}
return nullptr;
@ -512,15 +512,15 @@ int gui_update()
{
char tmp[MAX_DPATH];
fetch_statefilepath(savestate_fname, MAX_DPATH);
fetch_statefilepath(savestate_fname, sizeof savestate_fname);
fetch_screenshotpath(screenshot_filename, MAX_DPATH);
if (strlen(currprefs.floppyslots[0].df) > 0)
extractFileName(currprefs.floppyslots[0].df, tmp);
else
strncpy(tmp, last_loaded_config, MAX_DPATH);
strncpy(tmp, last_loaded_config, sizeof tmp);
strncat(savestate_fname, tmp, MAX_DPATH);
strncat(savestate_fname, tmp, sizeof savestate_fname);
strncat(screenshot_filename, tmp, MAX_DPATH);
removeFileExtension(savestate_fname);
removeFileExtension(screenshot_filename);

View file

@ -330,10 +330,10 @@ static void parse_boot(struct uae_prefs *p, xmlNode *node)
if(content != NULL)
{
char target_file[MAX_DPATH];
fetch_rp9path(target_file, MAX_DPATH);
strncat(target_file, "workbench-", MAX_DPATH);
strncat(target_file, (const char *)content, MAX_DPATH);
strncat(target_file, ".hdf", MAX_DPATH);
fetch_rp9path(target_file, sizeof target_file);
strncat(target_file, "workbench-", sizeof target_file);
strncat(target_file, (const char *)content, sizeof target_file);
strncat(target_file, ".hdf", sizeof target_file);
FILE *f = fopen(target_file, "rb");
if(f != NULL)
{
@ -420,7 +420,7 @@ static void extract_media(struct uae_prefs *p, unzFile uz, xmlNode *node)
char target_file[MAX_DPATH];
if(!my_existsdir(rp9tmp_path))
my_mkdir(rp9tmp_path);
snprintf(target_file, MAX_DPATH, "%s%s", rp9tmp_path, content);
snprintf(target_file, sizeof target_file, "%s%s", rp9tmp_path, content);
FILE *f = fopen(target_file, "wb");
if(f != NULL)
{

View file

@ -11,7 +11,7 @@
#include "gui.h"
#include "gui_handling.h"
static char last_active_config[MAX_PATH] = {'\0'};
static char last_active_config[MAX_DPATH] = {'\0'};
static int ensureVisible = -1;
static gcn::Button* cmdLoad;
@ -35,7 +35,7 @@ bool LoadConfigByName(const char* name)
txtName->setText(config->Name);
txtDesc->setText(config->Description);
target_cfgfile_load(&changed_prefs, config->FullPath, 0, 0);
strncpy(last_active_config, config->Name, MAX_PATH);
strncpy(last_active_config, config->Name, sizeof config->Name);
DisableResume();
RefreshAllPanels();
}
@ -99,12 +99,12 @@ public:
for (int i = 0; i < ConfigFilesList.size(); ++i)
{
char tmp[MAX_DPATH];
strncpy(tmp, ConfigFilesList[i]->Name, MAX_DPATH);
strncpy(tmp, ConfigFilesList[i]->Name, sizeof tmp);
if (strlen(ConfigFilesList[i]->Description) > 0)
{
strncat(tmp, " (", MAX_DPATH);
strncat(tmp, " (", sizeof tmp);
strncat(tmp, ConfigFilesList[i]->Description, 255);
strncat(tmp, ")", MAX_DPATH);
strncat(tmp, ")", sizeof tmp);
}
configs.push_back(tmp);
}
@ -137,7 +137,7 @@ public:
{
target_cfgfile_load(&changed_prefs, ConfigFilesList[i]->FullPath, 0, 0);
}
strncpy(last_active_config, ConfigFilesList[i]->Name, MAX_PATH);
strncpy(last_active_config, ConfigFilesList[i]->Name, sizeof last_active_config);
DisableResume();
RefreshAllPanels();
}
@ -150,9 +150,9 @@ public:
char filename[MAX_DPATH];
if (!txtName->getText().empty())
{
fetch_configurationpath(filename, MAX_DPATH);
fetch_configurationpath(filename, sizeof filename);
strncat(filename, txtName->getText().c_str(), 255);
strncat(filename, ".uae", MAX_DPATH);
strncat(filename, ".uae", sizeof filename);
strncpy(changed_prefs.description, txtDesc->getText().c_str(), 255);
if (cfgfile_save(&changed_prefs, filename, 0))
RefreshPanelConfig();
@ -169,11 +169,11 @@ public:
//-----------------------------------------------
// Delete selected config
//-----------------------------------------------
char msg[MAX_PATH];
char msg[MAX_DPATH];
i = lstConfigs->getSelected();
if (i >= 0 && ConfigFilesList[i]->BuiltInID == BUILTINID_NONE && strcmp(ConfigFilesList[i]->Name, OPTIONSFILENAME))
{
snprintf(msg, 256, "Do you want to delete '%s' ?", ConfigFilesList[i]->Name);
snprintf(msg, sizeof msg, "Do you want to delete '%s' ?", ConfigFilesList[i]->Name);
if (ShowMessage("Delete Configuration", msg, "", "Yes", "No"))
{
remove(ConfigFilesList[i]->FullPath);
@ -216,7 +216,7 @@ public:
{
target_cfgfile_load(&changed_prefs, ConfigFilesList[selected_item]->FullPath, 0, 0);
}
strncpy(last_active_config, ConfigFilesList[selected_item]->Name, MAX_PATH);
strncpy(last_active_config, ConfigFilesList[selected_item]->Name, sizeof ConfigFilesList[selected_item]->Name);
DisableResume();
RefreshAllPanels();
}
@ -318,7 +318,7 @@ void InitPanelConfig(const struct _ConfigCategory& category)
category.panel->add(txtDesc, DISTANCE_BORDER + lblDesc->getWidth() + 8, txtName->getY() + txtName->getHeight() + DISTANCE_NEXT_Y);
if (strlen(last_active_config) == 0)
strncpy(last_active_config, OPTIONSFILENAME, MAX_PATH);
strncpy(last_active_config, OPTIONSFILENAME, MAX_DPATH);
txtName->setText(last_active_config);
txtDesc->setText(changed_prefs.description);
ensureVisible = -1;

View file

@ -174,15 +174,15 @@ public:
//---------------------------------------
// Select disk for drive
//---------------------------------------
char tmp[MAX_PATH];
char tmp[MAX_DPATH];
if (strlen(changed_prefs.floppyslots[i].df) > 0)
strncpy(tmp, changed_prefs.floppyslots[i].df, MAX_PATH);
strncpy(tmp, changed_prefs.floppyslots[i].df, sizeof changed_prefs.floppyslots[i].df);
else
strncpy(tmp, currentDir, MAX_PATH);
strncpy(tmp, currentDir, sizeof currentDir);
if (SelectFile("Select disk image file", tmp, diskfile_filter))
{
if (strncmp(changed_prefs.floppyslots[i].df, tmp, MAX_PATH))
if (strncmp(changed_prefs.floppyslots[i].df, tmp, sizeof changed_prefs.floppyslots[i].df))
{
strncpy(changed_prefs.floppyslots[i].df, tmp, sizeof changed_prefs.floppyslots[i].df);
disk_insert(i, tmp);
@ -248,7 +248,7 @@ public:
if (i == 0 && chkLoadConfig->isSelected())
{
// Search for config of disk
char tmp[MAX_PATH];
char tmp[MAX_DPATH];
extractFileName(changed_prefs.floppyslots[i].df, tmp);
removeFileExtension(tmp);
@ -289,17 +289,17 @@ public:
//---------------------------------------
if (strlen(changed_prefs.floppyslots[0].df) > 0)
{
char filename[MAX_PATH];
char filename[MAX_DPATH];
char diskname[MAX_DPATH];
extractFileName(changed_prefs.floppyslots[0].df, diskname);
removeFileExtension(diskname);
fetch_configurationpath(filename, MAX_PATH);
strncat(filename, diskname, MAX_DPATH);
strncat(filename, ".uae", MAX_PATH);
fetch_configurationpath(filename, sizeof filename);
strncat(filename, diskname, sizeof diskname);
strncat(filename, ".uae", sizeof filename);
snprintf(changed_prefs.description, 255, "Configuration for disk '%s'", diskname);
snprintf(changed_prefs.description, sizeof changed_prefs.description, "Configuration for disk '%s'", diskname);
if (cfgfile_save(&changed_prefs, filename, 0))
RefreshPanelConfig();
}
@ -317,9 +317,9 @@ public:
if (actionEvent.getSource() == cmdCreateDDDisk)
{
// Create 3.5'' DD Disk
char tmp[MAX_PATH];
char diskname[MAX_PATH];
strncpy(tmp, currentDir, MAX_PATH);
char tmp[MAX_DPATH];
char diskname[MAX_DPATH];
strncpy(tmp, currentDir, sizeof tmp);
if (SelectFile("Create 3.5'' DD disk file", tmp, diskfile_filter, true))
{
extractFileName(tmp, diskname);
@ -334,9 +334,9 @@ public:
else if (actionEvent.getSource() == cmdCreateHDDisk)
{
// Create 3.5'' HD Disk
char tmp[MAX_PATH];
char diskname[MAX_PATH];
strncpy(tmp, currentDir, MAX_PATH);
char tmp[MAX_DPATH];
char diskname[MAX_DPATH];
strncpy(tmp, currentDir, sizeof tmp);
if (SelectFile("Create 3.5'' HD disk file", tmp, diskfile_filter, true))
{
extractFileName(tmp, diskname);

View file

@ -240,13 +240,13 @@ public:
char tmp[MAX_DPATH];
if (strlen(changed_prefs.cdslots[0].name) > 0)
strncpy(tmp, changed_prefs.cdslots[0].name, MAX_DPATH);
strncpy(tmp, changed_prefs.cdslots[0].name, sizeof tmp);
else
strncpy(tmp, currentDir, MAX_DPATH);
strncpy(tmp, currentDir, sizeof tmp);
if (SelectFile("Select CD image file", tmp, cdfile_filter))
{
if (strncmp(changed_prefs.cdslots[0].name, tmp, MAX_DPATH))
if (strncmp(changed_prefs.cdslots[0].name, tmp, sizeof changed_prefs.cdslots[0].name))
{
strncpy(changed_prefs.cdslots[0].name, tmp, sizeof(changed_prefs.cdslots[0].name));
changed_prefs.cdslots[0].inuse = true;

View file

@ -27,7 +27,7 @@ public:
if (actionEvent.getSource() == cmdSystemROMs)
{
fetch_rompath(tmp, MAX_PATH);
fetch_rompath(tmp, sizeof tmp);
if (SelectFolder("Folder for System ROMs", tmp))
{
set_rompath(tmp);
@ -37,7 +37,7 @@ public:
}
else if (actionEvent.getSource() == cmdConfigPath)
{
fetch_configurationpath(tmp, MAX_PATH);
fetch_configurationpath(tmp, sizeof tmp);
if (SelectFolder("Folder for configuration files", tmp))
{
set_configurationpath(tmp);
@ -140,9 +140,9 @@ void RefreshPanelPaths()
{
char tmp[MAX_PATH];
fetch_rompath(tmp, MAX_PATH);
fetch_rompath(tmp, sizeof tmp);
txtSystemROMs->setText(tmp);
fetch_configurationpath(tmp, MAX_PATH);
fetch_configurationpath(tmp, sizeof tmp);
txtConfigPath->setText(tmp);
}

View file

@ -121,14 +121,14 @@ public:
if (actionEvent.getSource() == cmdMainROM)
{
strncpy(tmp, currentDir, MAX_PATH);
strncpy(tmp, currentDir, sizeof tmp);
if (SelectFile("Select System ROM", tmp, filter))
{
AvailableROM* newrom;
newrom = new AvailableROM();
extractFileName(tmp, newrom->Name);
removeFileExtension(newrom->Name);
strncpy(newrom->Path, tmp, MAX_PATH);
strncpy(newrom->Path, tmp, sizeof newrom->Path);
newrom->ROMType = ROMTYPE_KICK;
lstAvailableROMs.push_back(newrom);
strncpy(changed_prefs.romfile, tmp, sizeof(changed_prefs.romfile));
@ -138,14 +138,14 @@ public:
}
else if (actionEvent.getSource() == cmdExtROM)
{
strncpy(tmp, currentDir, MAX_PATH);
strncpy(tmp, currentDir, sizeof tmp);
if (SelectFile("Select Extended ROM", tmp, filter))
{
AvailableROM* newrom;
newrom = new AvailableROM();
extractFileName(tmp, newrom->Name);
removeFileExtension(newrom->Name);
strncpy(newrom->Path, tmp, MAX_PATH);
strncpy(newrom->Path, tmp, sizeof newrom->Path);
newrom->ROMType = ROMTYPE_EXTCDTV;
lstAvailableROMs.push_back(newrom);
strncpy(changed_prefs.romextfile, tmp, sizeof(changed_prefs.romextfile));

View file

@ -385,7 +385,7 @@ bool SelectFile(const char* title, char* value, const char* filter[], bool creat
}
else
{
strncpy(value, workingDir, MAX_PATH);
strncpy(value, workingDir, sizeof value);
gui_top->add(wndSelectFile);
wndSelectFile->setCaption(title);
wndSelectFile->requestModalFocus();
@ -407,10 +407,10 @@ bool SelectFile(const char* title, char* value, const char* filter[], bool creat
ExitSelectFile();
#endif
if (dialogResult)
strncpy(value, workingDir, MAX_PATH);
strncpy(value, workingDir, sizeof value);
#ifdef FILE_SELECT_KEEP_POSITION
else
strncpy(workingDir, value, MAX_PATH);
strncpy(workingDir, value, sizeof workingDir);
#endif
return dialogResult;
}

View file

@ -270,7 +270,7 @@ bool SelectFolder(const char* title, char* value)
ExitSelectFolder();
if (dialogResult)
{
strncpy(value, workingDir, MAX_PATH);
strncpy(value, workingDir, sizeof value);
if (value[strlen(value) - 1] != '/')
strcat(value, "/");
}

View file

@ -384,8 +384,8 @@ namespace widgets
//-------------------------------------------------
// Restart emulator
//-------------------------------------------------
char tmp[MAX_PATH];
fetch_configurationpath(tmp, sizeof (tmp));
char tmp[MAX_DPATH];
fetch_configurationpath(tmp, sizeof tmp);
if (strlen(last_loaded_config) > 0)
strcat(tmp, last_loaded_config);
else

View file

@ -292,7 +292,7 @@ int loadconfig_old(struct uae_prefs* p, const char* orgpath)
}
if (p->nr_floppies > 3)
{
memset(filebuffer, 0, 256);
memset(filebuffer, 0, sizeof filebuffer);
fscanf(f, "df3=%s\n", &filebuffer);
replace(filebuffer, ' ', '|');
if (DISK_validate_filename(p, filebuffer, 0, nullptr, nullptr, nullptr))