cdrom: initialize all buffers used for drive paths, make sure to null-terminate filled paths in all cases
This commit is contained in:
parent
6065f71bb2
commit
3432f3b852
|
@ -1494,9 +1494,7 @@ bool cdrom_is_media_inserted(libretro_vfs_implementation_file *stream)
|
||||||
bool cdrom_drive_has_media(const char drive)
|
bool cdrom_drive_has_media(const char drive)
|
||||||
{
|
{
|
||||||
RFILE *file;
|
RFILE *file;
|
||||||
char cdrom_path_bin[256];
|
char cdrom_path_bin[256] = {0};
|
||||||
|
|
||||||
cdrom_path_bin[0] = '\0';
|
|
||||||
|
|
||||||
cdrom_device_fillpath(cdrom_path_bin, sizeof(cdrom_path_bin), drive, 1, false);
|
cdrom_device_fillpath(cdrom_path_bin, sizeof(cdrom_path_bin), drive, 1, false);
|
||||||
|
|
||||||
|
@ -1690,8 +1688,11 @@ void cdrom_device_fillpath(char *path, size_t len, char drive, unsigned char tra
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
pos = strlcpy(path, "cdrom://drive", len);
|
pos = strlcpy(path, "cdrom://drive", len);
|
||||||
|
|
||||||
if (len > pos)
|
if (len > pos + 1)
|
||||||
|
{
|
||||||
path[pos++] = drive;
|
path[pos++] = drive;
|
||||||
|
path[pos] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
pos = strlcat(path, ".cue", len);
|
pos = strlcat(path, ".cue", len);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1702,8 +1703,11 @@ void cdrom_device_fillpath(char *path, size_t len, char drive, unsigned char tra
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
pos = strlcpy(path, "cdrom://", len);
|
pos = strlcpy(path, "cdrom://", len);
|
||||||
|
|
||||||
if (len > pos)
|
if (len > pos + 1)
|
||||||
|
{
|
||||||
path[pos++] = drive;
|
path[pos++] = drive;
|
||||||
|
path[pos] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
pos += snprintf(path + pos, len - pos, ":/drive-track%02d.bin", track);
|
pos += snprintf(path + pos, len - pos, ":/drive-track%02d.bin", track);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -2263,9 +2263,7 @@ static int action_ok_load_cdrom(const char *path,
|
||||||
|
|
||||||
if (system && !string_is_empty(system->library_name))
|
if (system && !string_is_empty(system->library_name))
|
||||||
{
|
{
|
||||||
char cdrom_path[256];
|
char cdrom_path[256] = {0};
|
||||||
|
|
||||||
cdrom_path[0] = '\0';
|
|
||||||
|
|
||||||
cdrom_device_fillpath(cdrom_path, sizeof(cdrom_path), label[0], 0, true);
|
cdrom_device_fillpath(cdrom_path, sizeof(cdrom_path), label[0], 0, true);
|
||||||
|
|
||||||
|
|
|
@ -5187,14 +5187,13 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||||
case DISPLAYLIST_CDROM_DETAIL_INFO:
|
case DISPLAYLIST_CDROM_DETAIL_INFO:
|
||||||
{
|
{
|
||||||
media_detect_cd_info_t cd_info = {{0}};
|
media_detect_cd_info_t cd_info = {{0}};
|
||||||
char file_path[PATH_MAX_LENGTH];
|
char file_path[PATH_MAX_LENGTH] = {0};
|
||||||
RFILE *file;
|
RFILE *file;
|
||||||
char drive = info->path[0];
|
char drive = info->path[0];
|
||||||
bool atip = false;
|
bool atip = false;
|
||||||
|
|
||||||
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
|
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
|
||||||
count = 0;
|
count = 0;
|
||||||
file_path[0] = '\0';
|
|
||||||
|
|
||||||
if (cdrom_drive_has_media(drive))
|
if (cdrom_drive_has_media(drive))
|
||||||
{
|
{
|
||||||
|
@ -5226,6 +5225,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* open first data track */
|
/* open first data track */
|
||||||
|
memset(file_path, 0, sizeof(file_path));
|
||||||
cdrom_device_fillpath(file_path, sizeof(file_path), drive, first_data_track, false);
|
cdrom_device_fillpath(file_path, sizeof(file_path), drive, first_data_track, false);
|
||||||
|
|
||||||
if (media_detect_cd_info(file_path, 0, &cd_info))
|
if (media_detect_cd_info(file_path, 0, &cd_info))
|
||||||
|
|
|
@ -230,9 +230,7 @@ static void task_cdrom_dump_handler(retro_task_t *task)
|
||||||
case DUMP_STATE_TOC_PENDING:
|
case DUMP_STATE_TOC_PENDING:
|
||||||
{
|
{
|
||||||
/* open cuesheet file from drive */
|
/* open cuesheet file from drive */
|
||||||
char cue_path[PATH_MAX_LENGTH];
|
char cue_path[PATH_MAX_LENGTH] = {0};
|
||||||
|
|
||||||
cue_path[0] = '\0';
|
|
||||||
|
|
||||||
cdrom_device_fillpath(cue_path, sizeof(cue_path), state->drive_letter[0], 0, true);
|
cdrom_device_fillpath(cue_path, sizeof(cue_path), state->drive_letter[0], 0, true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue