diff --git a/src/config.c b/src/config.c index 63e7fb3fa..6e6791f8d 100644 --- a/src/config.c +++ b/src/config.c @@ -985,6 +985,18 @@ load_image_file(char *dest, char *p, uint8_t *ui_wp) } else if ((ui_wp != NULL) && *ui_wp) prefix = "wp://"; + if (strstr(p, "ioctl://") == p) { + if (strlen(p) > (MAX_IMAGE_PATH_LEN - 11)) + ret = 1; + else + snprintf(dest, MAX_IMAGE_PATH_LEN, "%s", p); + + if (above != NULL) + free(above); + + return ret; + } + if (memcmp(p, "/", strlen("/")) == 0) { if ((strlen(prefix) + strlen(exe_path) + strlen(path_get_slash(exe_path)) + strlen(p + strlen("/"))) > (MAX_IMAGE_PATH_LEN - 11)) @@ -1374,17 +1386,15 @@ load_hard_disks(void) p[0] = 0x00; if (p[0] != 0x00) { - if (path_abs(p)) { - if (strlen(p) > 511) - fatal("Configuration: Length of hdd_%02i_fn is more " - "than 511\n", c + 1); - else - strncpy(hdd[c].fn, p, 511); - } else - path_append_filename(hdd[c].fn, usr_path, p); - path_normalize(hdd[c].fn); + if (load_image_file(hdd[c].fn, p, NULL)) + fatal("Configuration: Length of hdd_%02i_fn is more than 511\n", c + 1); } +#if defined(ENABLE_CONFIG_LOG) && (ENABLE_CONFIG_LOG == 2) + if (*p != '\0') + config_log("HDD%d: %ls\n", c, hdd[c].fn); +#endif + sprintf(temp, "hdd_%02i_vhd_blocksize", c + 1); hdd[c].vhd_blocksize = ini_section_get_int(cat, temp, 0); @@ -1472,6 +1482,7 @@ load_floppy_and_cdrom_drives(void) if (*p != '\0') config_log("Floppy%d: %ls\n", c, floppyfns[c]); #endif + sprintf(temp, "fdd_%02i_turbo", c + 1); fdd_set_turbo(c, !!ini_section_get_int(cat, temp, 0)); sprintf(temp, "fdd_%02i_check_bpb", c + 1); @@ -1627,31 +1638,23 @@ load_floppy_and_cdrom_drives(void) p[0] = 0x00; if (p[0] != 0x00) { - if (path_abs(p)) { - if (strlen(p) > 511) - fatal("Configuration: Length of cdrom_%02i_image_path is more than 511\n", c + 1); - else - strncpy(cdrom[c].image_path, p, 511); - } else - path_append_filename(cdrom[c].image_path, usr_path, p); - path_normalize(cdrom[c].image_path); + if (load_image_file(cdrom[c].image_path, p, NULL)) + fatal("Configuration: Length of cdrom_%02i_image_path is more than 511\n", c + 1); } +#if defined(ENABLE_CONFIG_LOG) && (ENABLE_CONFIG_LOG == 2) + if (*p != '\0') + config_log("CD-ROM%d: %ls\n", c, cdrom[c].image_path); +#endif + for (int i = 0; i < MAX_PREV_IMAGES; i++) { cdrom[c].image_history[i] = (char *) calloc((MAX_IMAGE_PATH_LEN + 1) << 1, sizeof(char)); sprintf(temp, "cdrom_%02i_image_history_%02i", c + 1, i + 1); p = ini_section_get_string(cat, temp, NULL); if (p) { - if (path_abs(p)) { - if (strlen(p) > (MAX_IMAGE_PATH_LEN - 1)) - fatal("Configuration: Length of cdrom_%02i_image_history_%02i is more " - "than %i\n", c + 1, i + 1, MAX_IMAGE_PATH_LEN - 1); - else - snprintf(cdrom[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s", p); - } else - snprintf(cdrom[c].image_history[i], MAX_IMAGE_PATH_LEN, "%s%s%s", usr_path, - path_get_slash(usr_path), p); - path_normalize(cdrom[c].image_history[i]); + if (load_image_file(cdrom[c].image_history[i], p, NULL)) + fatal("Configuration: Length of cdrom_%02i_image_history_%02i is more " + "than %i\n", c + 1, i + 1, MAX_IMAGE_PATH_LEN - 1); } } @@ -3110,7 +3113,9 @@ save_image_file(char *cat, char *var, char *src) prefix = "wp://"; } - if (!strnicmp(src, usr_path, strlen(usr_path))) + if (strstr(src, "ioctl://") == src) + sprintf(temp, "%s", src); + else if (!strnicmp(src, usr_path, strlen(usr_path))) sprintf(temp, "%s%s", prefix, &src[strlen(usr_path)]); else if ((above != NULL) && !strnicmp(src, above, strlen(above))) sprintf(temp, "../%s%s", prefix, &src[strlen(above)]); @@ -3431,13 +3436,9 @@ save_hard_disks(void) } sprintf(temp, "hdd_%02i_fn", c + 1); - if (hdd_is_valid(c) && (strlen(hdd[c].fn) != 0)) { - path_normalize(hdd[c].fn); - if (!strnicmp(hdd[c].fn, usr_path, strlen(usr_path))) - ini_section_set_string(cat, temp, &hdd[c].fn[strlen(usr_path)]); - else - ini_section_set_string(cat, temp, hdd[c].fn); - } else + if (hdd_is_valid(c) && (strlen(hdd[c].fn) != 0)) + save_image_file(cat, temp, hdd[c].fn); + else ini_section_delete_var(cat, temp); sprintf(temp, "hdd_%02i_vhd_blocksize", c + 1); @@ -3598,25 +3599,15 @@ save_floppy_and_cdrom_drives(void) sprintf(temp, "cdrom_%02i_image_path", c + 1); if ((cdrom[c].bus_type == 0) || (strlen(cdrom[c].image_path) == 0)) ini_section_delete_var(cat, temp); - else { - path_normalize(cdrom[c].image_path); - if (!strnicmp(cdrom[c].image_path, usr_path, strlen(usr_path))) - ini_section_set_string(cat, temp, &cdrom[c].image_path[strlen(usr_path)]); - else - ini_section_set_string(cat, temp, cdrom[c].image_path); - } + else + save_image_file(cat, temp, cdrom[c].image_path); for (int i = 0; i < MAX_PREV_IMAGES; i++) { sprintf(temp, "cdrom_%02i_image_history_%02i", c + 1, i + 1); if ((cdrom[c].image_history[i] == 0) || strlen(cdrom[c].image_history[i]) == 0) ini_section_delete_var(cat, temp); - else { - path_normalize(cdrom[c].image_history[i]); - if (!strnicmp(cdrom[c].image_history[i], usr_path, strlen(usr_path))) - ini_section_set_string(cat, temp, &cdrom[c].image_history[i][strlen(usr_path)]); - else - ini_section_set_string(cat, temp, cdrom[c].image_history[i]); - } + else + save_image_file(cat, temp, cdrom[c].image_history[i]); } }