diff --git a/src/iso.c b/src/iso.c index 75831516..ddc16807 100644 --- a/src/iso.c +++ b/src/iso.c @@ -1096,7 +1096,7 @@ out: if ((iso9660_ifs_read_pvd(p_iso, &pvd)) && (_stat64U(src_iso, &stat) == 0)) img_report.mismatch_size = (int64_t)(iso9660_get_pvd_space_size(&pvd)) * ISO_BLOCKSIZE - stat.st_size; // Remove trailing spaces from the label - for (k=(int)safe_strlen(img_report.label)-1; ((k>0)&&(isspaceU(img_report.label[k]))); k--) + for (k = (int)safe_strlen(img_report.label) - 1; ((k > 0) && (isspaceU(img_report.label[k]))); k--) img_report.label[k] = 0; // We use the fact that UDF_BLOCKSIZE and ISO_BLOCKSIZE are the same here img_report.projected_size = total_blocks * ISO_BLOCKSIZE; @@ -1106,9 +1106,9 @@ out: if (!IsStrArrayEmpty(config_path)) { // Set the img_report.cfg_path string to maximum length, so that we don't have to // do a special case for StrArray entry 0. - memset(img_report.cfg_path, '_', sizeof(img_report.cfg_path)-1); - img_report.cfg_path[sizeof(img_report.cfg_path)-1] = 0; - for (i=0; i0) && (img_report.cfg_path[j]!='/'); j--); + for (j=safe_strlen(img_report.cfg_path); (j > 0) && (img_report.cfg_path[j] != '/'); j--); if (safe_strnicmp(img_report.cfg_path, isolinux_path.String[i], j) == 0) { static_strcpy(img_report.sl_version_ext, ext); img_report.sl_version = sl_version; @@ -1197,7 +1197,7 @@ out: ExtractISOFile(src_iso, path, tmp_sif, FILE_ATTRIBUTE_NORMAL); tmp = get_token_data_file("OsLoadOptions", tmp_sif); if (tmp != NULL) { - for (i=0; i= 5)); - PrintInfoDebug(0, MSG_234, (boot_type == BT_IMAGE)?img_report.sl_version_str:embedded_sl_version_str[use_v5?1:0]); + PrintInfoDebug(0, MSG_234, (boot_type == BT_IMAGE) ? img_report.sl_version_str : embedded_sl_version_str[use_v5?1:0]); /* 4K sector size workaround */ SECTOR_SHIFT = 0; @@ -287,8 +287,14 @@ BOOL InstallSyslinux(DWORD drive_index, char drive_letter, int file_system) goto out; } - /* Patch ldlinux.sys and the boot sector */ - if (syslinux_patch(sectors, nsectors, 0, 0, NULL, NULL) < 0) { + /* Set the base directory and patch ldlinux.sys and the boot sector */ + for (i = (int)strlen(img_report.cfg_path); (i > 0) && (img_report.cfg_path[i] != '/'); i--); + if (i > 0) + img_report.cfg_path[i] = 0; + w = syslinux_patch(sectors, nsectors, 0, 0, img_report.cfg_path, NULL); + if (i > 0) + img_report.cfg_path[i] = '/'; + if (w < 0) { uprintf("Could not patch Syslinux files."); uprintf("WARNING: This could be caused by your firewall having modified downloaded content, such as 'ldlinux.sys'..."); goto out; diff --git a/src/syslinux/libinstaller/syslxmod.c b/src/syslinux/libinstaller/syslxmod.c index 23a10217..19e1fa82 100644 --- a/src/syslinux/libinstaller/syslxmod.c +++ b/src/syslinux/libinstaller/syslxmod.c @@ -28,6 +28,7 @@ #include "syslinux.h" #include "syslxint.h" +extern void uprintf(const char* format, ...); /* * Generate sector extents @@ -161,8 +162,8 @@ int syslinux_patch(const sector_t *sectp, int nsectors, #if 0 if (nsect > nptrs) { /* Not necessarily an error in this case, but a general problem */ - fprintf(stderr, "Insufficient extent space, build error!\n"); - exit(1); + uprintf("syslinux_patch: Insufficient extent space, build error!\n"); + return -1; } #endif @@ -178,8 +179,8 @@ int syslinux_patch(const sector_t *sectp, int nsectors, if (subdir) { int sublen = strlen(subdir) + 1; if (get_16_sl(&epa->dirlen) < sublen) { - fprintf(stderr, "Subdirectory path too long... aborting install!\n"); - exit(1); + uprintf("syslinux_patch: Subdirectory path too long... aborting install!"); + return -1; } memcpy_to_sl(slptr(boot_image, &epa->diroffset), subdir, sublen); } @@ -188,8 +189,8 @@ int syslinux_patch(const sector_t *sectp, int nsectors, if (subvol) { int sublen = strlen(subvol) + 1; if (get_16_sl(&epa->subvollen) < sublen) { - fprintf(stderr, "Subvol name too long... aborting install!\n"); - exit(1); + uprintf("syslinux_patch: Subvol name too long... aborting install!"); + return -1; } memcpy_to_sl(slptr(boot_image, &epa->subvoloffset), subvol, sublen); } diff --git a/src/syslinux/win/ntfssect.c b/src/syslinux/win/ntfssect.c index 15d2709c..5c076499 100644 --- a/src/syslinux/win/ntfssect.c +++ b/src/syslinux/win/ntfssect.c @@ -126,10 +126,10 @@ static DWORD NtfsSectGetVolumeHandle( M_ERR("Unable to open volume handle!"); goto err_handle; } + CloseHandle(VolumeInfo->Handle); return ERROR_SUCCESS; - CloseHandle(VolumeInfo->Handle); err_handle: return rc;