mirror of https://github.com/snes9xgit/snes9x.git
Use a sstrncpy function that behaves like strlcpy.
This commit is contained in:
parent
600de05244
commit
047cfe2f9d
|
@ -456,7 +456,7 @@ S9xOpenROMDialog ()
|
|||
gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
|
||||
if (directory)
|
||||
{
|
||||
strncpy (gui_config->last_directory, directory, PATH_MAX - 1);
|
||||
sstrncpy (gui_config->last_directory, directory, PATH_MAX);
|
||||
g_free (directory);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,8 +96,8 @@ Snes9xNetplayDialog::settings_to_dialog ()
|
|||
void
|
||||
Snes9xNetplayDialog::settings_from_dialog ()
|
||||
{
|
||||
strncpy (config->netplay_last_rom, get_entry_text ("rom_image"), PATH_MAX - 1);
|
||||
strncpy (config->netplay_last_host, get_entry_text ("ip_entry"), PATH_MAX - 1);
|
||||
sstrncpy (config->netplay_last_rom, get_entry_text ("rom_image"), PATH_MAX);
|
||||
sstrncpy (config->netplay_last_host, get_entry_text ("ip_entry"), PATH_MAX);
|
||||
config->netplay_sync_reset = get_check ("sync_reset");
|
||||
config->netplay_send_rom = get_check ("send_image");
|
||||
config->netplay_last_port = get_spin ("port");
|
||||
|
|
|
@ -905,17 +905,17 @@ Snes9xPreferences::get_settings_from_dialog ()
|
|||
config->use_shaders = get_check ("use_shaders");
|
||||
config->sync_every_frame = get_check ("sync_every_frame");
|
||||
|
||||
strncpy (config->fragment_shader, get_entry_text ("fragment_shader"), PATH_MAX - 1);
|
||||
sstrncpy (config->fragment_shader, get_entry_text ("fragment_shader"), PATH_MAX);
|
||||
|
||||
config->pbo_format = pbo_format;
|
||||
#endif
|
||||
char safety_sram_directory [PATH_MAX];
|
||||
|
||||
strncpy (safety_sram_directory, get_entry_text ("sram_directory"), PATH_MAX - 1);
|
||||
strncpy (config->savestate_directory, get_entry_text ("savestate_directory"), PATH_MAX - 1);
|
||||
strncpy (config->patch_directory, get_entry_text ("patch_directory"), PATH_MAX - 1);
|
||||
strncpy (config->cheat_directory, get_entry_text ("cheat_directory"), PATH_MAX - 1);
|
||||
strncpy (config->export_directory, get_entry_text ("export_directory"), PATH_MAX - 1);
|
||||
sstrncpy (safety_sram_directory, get_entry_text ("sram_directory"), PATH_MAX);
|
||||
sstrncpy (config->savestate_directory, get_entry_text ("savestate_directory"), PATH_MAX);
|
||||
sstrncpy (config->patch_directory, get_entry_text ("patch_directory"), PATH_MAX);
|
||||
sstrncpy (config->cheat_directory, get_entry_text ("cheat_directory"), PATH_MAX);
|
||||
sstrncpy (config->export_directory, get_entry_text ("export_directory"), PATH_MAX);
|
||||
|
||||
if (!strcmp (safety_sram_directory, SAME_GAME))
|
||||
safety_sram_directory[0] = '\0';
|
||||
|
|
|
@ -434,7 +434,7 @@ static int read_movie_extrarominfo (FILE *fd, SMovie *movie)
|
|||
|
||||
ptr += 3; // zero bytes
|
||||
movie->ROMCRC32 = Read32(ptr);
|
||||
strncpy(movie->ROMName, (char *) ptr, 22);
|
||||
sstrncpy(movie->ROMName, (char *) ptr, 23);
|
||||
|
||||
return (SUCCESS);
|
||||
}
|
||||
|
|
3
port.h
3
port.h
|
@ -148,7 +148,8 @@ void SetInfoDlgColor(unsigned char, unsigned char, unsigned char);
|
|||
#endif // __LIBRETRO__
|
||||
#endif // __WIN32__
|
||||
|
||||
#define ssnprintf(dst, size, fmt, ...) if (snprintf (dst, size, fmt, __VA_ARGS__) >= (int) size) dst[size - 1] = '\0';
|
||||
#define ssnprintf(dst, size, fmt, ...) if (snprintf(dst, size, fmt, __VA_ARGS__) >= (int) size) dst[size - 1] = '\0';
|
||||
#define sstrncpy(dst, src, size) strncpy(dst, src, size - 1); dst[size - 1] = '\0';
|
||||
|
||||
#if defined(__DJGPP) || defined(__WIN32__)
|
||||
#define SLASH_STR "\\"
|
||||
|
|
Loading…
Reference in New Issue