mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[iso] fixes for Joliet and > 4GB ISO9660 images
* scan would fail on lowercase vs mixed case dir name comparison due to Joliet (eg. using Slackware 13.37 ISO) * extraction would fail for 4 GB ISO9660 ISOs * also fixes cases issue when checking for isolinux/bootmgr * also don't restrict NTFS labels
This commit is contained in:
		
							parent
							
								
									f4ed6e4650
								
							
						
					
					
						commit
						3cd83869c4
					
				
					 5 changed files with 87 additions and 80 deletions
				
			
		
							
								
								
									
										50
									
								
								src/format.c
									
										
									
									
									
								
							
							
						
						
									
										50
									
								
								src/format.c
									
										
									
									
									
								
							|  | @ -136,6 +136,47 @@ static BOOLEAN __stdcall FormatExCallback(FILE_SYSTEM_CALLBACK_COMMAND Command, | |||
| 	return (!IS_ERROR(FormatStatus)); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * Converts an UTF-16 label to a valid FAT/NTFS one | ||||
|  */ | ||||
| static void ToValidLabel(WCHAR* name, BOOL bFAT) | ||||
| { | ||||
| 	size_t i, j, k; | ||||
| 	BOOL found; | ||||
| 	WCHAR unauthorized[] = L"*?.,;:/\\|+=<>[]"; | ||||
| 	WCHAR to_underscore[] = L"\t"; | ||||
| 
 | ||||
| 	if (name == NULL) | ||||
| 		return; | ||||
| 
 | ||||
| 	for (i=0, k=0; i<wcslen(name); i++) { | ||||
| 		if (bFAT) {	// NTFS does allows all the FAT unauthorized above
 | ||||
| 			found = FALSE; | ||||
| 			for (j=0; j<wcslen(unauthorized); j++) { | ||||
| 				if (name[i] == unauthorized[j]) { | ||||
| 					found = TRUE; break; | ||||
| 				} | ||||
| 			} | ||||
| 			if (found) continue; | ||||
| 		} | ||||
| 		found = FALSE; | ||||
| 		for (j=0; j<wcslen(to_underscore); j++) { | ||||
| 			if (name[i] == to_underscore[j]) { | ||||
| 				name[k++] = '_'; | ||||
| 				found = TRUE; break; | ||||
| 			} | ||||
| 		} | ||||
| 		if (found) continue; | ||||
| 		name[k++] = name[i]; | ||||
| 	} | ||||
| 	name[k] = 0; | ||||
| 	if (bFAT) { | ||||
| 		name[11] = 0; | ||||
| 	} else { | ||||
| 		name[32] = 0; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * Call on fmifs.dll's FormatEx() to format the drive | ||||
|  */ | ||||
|  | @ -145,7 +186,7 @@ static BOOL FormatDrive(char DriveLetter) | |||
| 	PF_DECL(FormatEx); | ||||
| 	WCHAR wDriveRoot[] = L"?:\\"; | ||||
| 	WCHAR wFSType[32]; | ||||
| 	WCHAR wLabel[128]; | ||||
| 	WCHAR wLabel[64]; | ||||
| 	size_t i; | ||||
| 
 | ||||
| 	wDriveRoot[0] = (WCHAR)DriveLetter; | ||||
|  | @ -161,11 +202,8 @@ static BOOL FormatDrive(char DriveLetter) | |||
| 		} | ||||
| 	} | ||||
| 	GetWindowTextW(hLabel, wLabel, ARRAYSIZE(wLabel)); | ||||
| 	// If using FAT/FAT32, truncate the label to 11 characters
 | ||||
| 	// TODO: use a wchar_t to_valid_label() here
 | ||||
| 	if ((wFSType[0] == 'F') && (wFSType[1] == 'A') && (wFSType[2] == 'T')) { | ||||
| 		wLabel[11] = 0; | ||||
| 	} | ||||
| 	// Make sure the label is valid
 | ||||
| 	ToValidLabel(wLabel, (wFSType[0] == 'F') && (wFSType[1] == 'A') && (wFSType[2] == 'T')); | ||||
| 	uprintf("Using cluster size: %d bytes\n", ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize))); | ||||
| 	format_percent = 0.0f; | ||||
| 	task_number = 0; | ||||
|  |  | |||
							
								
								
									
										23
									
								
								src/iso.c
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								src/iso.c
									
										
									
									
									
								
							|  | @ -66,6 +66,7 @@ static const char *psz_extract_dir; | |||
| static const char *bootmgr_name = "bootmgr"; | ||||
| static const char *ldlinux_name = "ldlinux.sys"; | ||||
| static const char *isolinux_name[] = { "isolinux.cfg", "syslinux.cfg", "extlinux.conf"}; | ||||
| static uint8_t i_joliet_level = 0; | ||||
| static uint64_t total_blocks, nb_blocks; | ||||
| static BOOL scan_only = FALSE; | ||||
| 
 | ||||
|  | @ -94,7 +95,6 @@ static void log_handler (cdio_log_level_t level, const char *message) | |||
| { | ||||
| 	switch(level) { | ||||
| 	case CDIO_LOG_DEBUG: | ||||
| 	case CDIO_LOG_INFO: | ||||
| 		return; | ||||
| 	default: | ||||
| 		uprintf("libcdio: %s\n", message); | ||||
|  | @ -142,11 +142,11 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha | |||
| 			i_file_length = udf_get_file_length(p_udf_dirent); | ||||
| 			if (scan_only) { | ||||
| 				// Check for a "bootmgr" file in root (psz_path = "")
 | ||||
| 				if ((*psz_path == 0) && (safe_strcmp(psz_basename, bootmgr_name) == 0)) | ||||
| 				if ((*psz_path == 0) && (_stricmp(psz_basename, bootmgr_name) == 0)) | ||||
| 					iso_report.has_bootmgr = TRUE; | ||||
| 				// Check for a syslinux config file anywhere
 | ||||
| 				for (i=0; i<ARRAYSIZE(isolinux_name); i++) { | ||||
| 					if (safe_strcmp(psz_basename, isolinux_name[i]) == 0) | ||||
| 					if (_stricmp(psz_basename, isolinux_name[i]) == 0) | ||||
| 						iso_report.has_isolinux = TRUE; | ||||
| 				} | ||||
| 				if (i_file_length >= FOUR_GIGABYTES) | ||||
|  | @ -244,14 +244,14 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path) | |||
| 	if (!p_entlist) | ||||
| 		return 1; | ||||
| 
 | ||||
| 	_CDIO_LIST_FOREACH (p_entnode, p_entlist) { | ||||
| 	_CDIO_LIST_FOREACH(p_entnode, p_entlist) { | ||||
| 		if (FormatStatus) goto out; | ||||
| 		p_statbuf = (iso9660_stat_t*) _cdio_list_node_data(p_entnode); | ||||
| 		/* Eliminate . and .. entries */ | ||||
| 		if ( (strcmp(p_statbuf->filename, ".") == 0) | ||||
| 			|| (strcmp(p_statbuf->filename, "..") == 0) ) | ||||
| 			continue; | ||||
| 		iso9660_name_translate(p_statbuf->filename, psz_basename); | ||||
| 		iso9660_name_translate_ext(p_statbuf->filename, psz_basename, i_joliet_level); | ||||
| 		if (p_statbuf->type == _STAT_DIR) { | ||||
| 			if (!scan_only) _mkdir(psz_fullpath); | ||||
| 			if (iso_extract_files(p_iso, psz_iso_name)) | ||||
|  | @ -260,11 +260,11 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path) | |||
| 			i_file_length = p_statbuf->size; | ||||
| 			if (scan_only) { | ||||
| 				// Check for a "bootmgr" file in root (psz_path = "")
 | ||||
| 				if ((*psz_path == 0) && (safe_strcmp(psz_basename, bootmgr_name) == 0)) | ||||
| 				if ((*psz_path == 0) && (_stricmp(psz_basename, bootmgr_name) == 0)) | ||||
| 					iso_report.has_bootmgr = TRUE; | ||||
| 				// Check for a syslinux config file anywhere
 | ||||
| 				for (i=0; i<ARRAYSIZE(isolinux_name); i++) { | ||||
| 					if (safe_strcmp(psz_basename, isolinux_name[i]) == 0) | ||||
| 					if (_stricmp(psz_basename, isolinux_name[i]) == 0) | ||||
| 						iso_report.has_isolinux = TRUE; | ||||
| 				} | ||||
| 				if (i_file_length >= FOUR_GIGABYTES) | ||||
|  | @ -276,7 +276,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path) | |||
| 			} else { | ||||
| 				// In case there's an ldlinux.sys on the ISO, prevent it from overwriting ours
 | ||||
| 				if ((*psz_path == 0) && (safe_strcmp(psz_basename, ldlinux_name) == 0)) { | ||||
| 					uprintf("skipping % file from ISO image\n", ldlinux_name); | ||||
| 					uprintf("Skipping % file from ISO image\n", ldlinux_name); | ||||
| 					continue; | ||||
| 				} | ||||
| 			} | ||||
|  | @ -389,12 +389,15 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, bool scan) | |||
| 	goto out; | ||||
| 
 | ||||
| try_iso: | ||||
| 	p_iso = iso9660_open(src_iso); | ||||
| 	p_iso = iso9660_open_ext(src_iso, 0xFF); | ||||
| 	if (p_iso == NULL) { | ||||
| 		uprintf("Unable to open image '%s'.\n", src_iso); | ||||
| 		goto out; | ||||
| 	} | ||||
| 	uprintf("Disc image is an ISO9660 image\n"); | ||||
| 	i_joliet_level = iso9660_ifs_get_joliet_level(p_iso); | ||||
| 	uprintf("Disc image is an ISO9660 image (Joliet = %d)\n", i_joliet_level); | ||||
| 	// FIXME: libcdio's Joliet detection seems broken => override
 | ||||
| 	i_joliet_level = ISO_EXTENSION_JOLIET_LEVEL3; | ||||
| 	if (scan_only) { | ||||
| 		if (iso9660_ifs_get_volume_id(p_iso, &vol_id)) | ||||
| 			safe_strcpy(iso_report.label, sizeof(iso_report.label), vol_id); | ||||
|  |  | |||
|  | @ -703,7 +703,7 @@ iso9660_seek_read_framesize (const iso9660_t *p_iso, void *ptr, | |||
| 			     uint16_t i_framesize) | ||||
| { | ||||
|   long int ret; | ||||
|   long int i_byte_offset; | ||||
|   int64_t i_byte_offset; | ||||
|    | ||||
|   if (!p_iso) return 0; | ||||
|   i_byte_offset = (start * p_iso->i_framesize) + p_iso->i_fuzzy_offset  | ||||
|  |  | |||
							
								
								
									
										80
									
								
								src/rufus.c
									
										
									
									
									
								
							
							
						
						
									
										80
									
								
								src/rufus.c
									
										
									
									
									
								
							|  | @ -952,41 +952,6 @@ BOOL CALLBACK ISOProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) | |||
| 	return FALSE;  | ||||
| }  | ||||
| 
 | ||||
| /*
 | ||||
|  * Converts a name + ext UTF-8 pair to a valid MS filename. | ||||
|  * Returned string is allocated and needs to be freed manually | ||||
|  */ | ||||
| void to_valid_label(char* name) | ||||
| { | ||||
| 	size_t i, j, k; | ||||
| 	BOOL found; | ||||
| 	char unauthorized[] = "*?.,;:/\\|+=<>[]"; | ||||
| 	char to_underscore[] = "\t"; | ||||
| 
 | ||||
| 	if (name == NULL) | ||||
| 		return; | ||||
| 
 | ||||
| 	for (i=0, k=0; i<strlen(name); i++) { | ||||
| 		found = FALSE; | ||||
| 		for (j=0; j<strlen(unauthorized); j++) { | ||||
| 			if (name[i] == unauthorized[j]) { | ||||
| 				found = TRUE; break; | ||||
| 			} | ||||
| 		} | ||||
| 		if (found) continue; | ||||
| 		found = FALSE; | ||||
| 		for (j=0; j<strlen(to_underscore); j++) { | ||||
| 			if (name[i] == to_underscore[j]) { | ||||
| 				name[k++] = '_'; | ||||
| 				found = TRUE; break; | ||||
| 			} | ||||
| 		} | ||||
| 		if (found) continue; | ||||
| 		name[k++] = name[i]; | ||||
| 	} | ||||
| 	name[k] = 0; | ||||
| } | ||||
| 
 | ||||
| // The scanning process can be blocking for message processing => use a thread
 | ||||
| DWORD WINAPI ISOScanThread(LPVOID param) | ||||
| { | ||||
|  | @ -1013,7 +978,6 @@ DWORD WINAPI ISOScanThread(LPVOID param) | |||
| 		// Some Linux distros, such as Arch Linux, require the USB drive to have
 | ||||
| 		// a specific label => copy the one we got from the ISO image
 | ||||
| 		if (iso_report.label[0] != 0) { | ||||
| 			to_valid_label(iso_report.label); | ||||
| 			SetWindowTextU(hLabel, iso_report.label); | ||||
| 		} | ||||
| 	} | ||||
|  | @ -1321,27 +1285,29 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA | |||
| 			FormatStatus = 0; | ||||
| 			nDeviceIndex = ComboBox_GetCurSel(hDeviceList); | ||||
| 			if (nDeviceIndex != CB_ERR) { | ||||
| 				dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)); | ||||
| 				if ((dt == DT_ISO_NTFS) || (dt == DT_ISO_FAT)) { | ||||
| 					if (iso_path == NULL) { | ||||
| 						MessageBoxA(hMainDialog, "Please click on the disc button to select a bootable ISO,\n" | ||||
| 							"or uncheck the \"Create a bootable disk...\" checkbox.", | ||||
| 							"No ISO image selected...", MB_OK|MB_ICONERROR); | ||||
| 						break; | ||||
| 					} | ||||
| 					if ((iso_size_check) && (iso_report.projected_size > (uint64_t)SelectedDrive.DiskSize)) { | ||||
| 						MessageBoxA(hMainDialog, "This ISO image is too big " | ||||
| 							"for the selected target.", "ISO image too big...", MB_OK|MB_ICONERROR); | ||||
| 						break; | ||||
| 					} | ||||
| 					if ((dt == DT_ISO_NTFS) && (!iso_report.has_bootmgr)) { | ||||
| 						MessageBoxA(hMainDialog, "Only 'bootmgr' based ISO " | ||||
| 							"images can be used with NTFS.", "Unsupported ISO...", MB_OK|MB_ICONERROR); | ||||
| 						break; | ||||
| 					} else if ((dt == DT_ISO_FAT) && (!iso_report.has_isolinux)) { | ||||
| 						MessageBoxA(hMainDialog, "Only 'isolinux' based ISO " | ||||
| 							"images can be used with FAT.", "Unsupported ISO...", MB_OK|MB_ICONERROR); | ||||
| 						break; | ||||
| 				if (IsChecked(IDC_DOS)) { | ||||
| 					dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)); | ||||
| 					if ((dt == DT_ISO_NTFS) || (dt == DT_ISO_FAT)) { | ||||
| 						if (iso_path == NULL) { | ||||
| 							MessageBoxA(hMainDialog, "Please click on the disc button to select a bootable ISO,\n" | ||||
| 								"or uncheck the \"Create a bootable disk...\" checkbox.", | ||||
| 								"No ISO image selected...", MB_OK|MB_ICONERROR); | ||||
| 							break; | ||||
| 						} | ||||
| 						if ((iso_size_check) && (iso_report.projected_size > (uint64_t)SelectedDrive.DiskSize)) { | ||||
| 							MessageBoxA(hMainDialog, "This ISO image is too big " | ||||
| 								"for the selected target.", "ISO image too big...", MB_OK|MB_ICONERROR); | ||||
| 							break; | ||||
| 						} | ||||
| 						if ((dt == DT_ISO_NTFS) && (!iso_report.has_bootmgr)) { | ||||
| 							MessageBoxA(hMainDialog, "Only 'bootmgr' based ISO " | ||||
| 								"images can be used with NTFS.", "Unsupported ISO...", MB_OK|MB_ICONERROR); | ||||
| 							break; | ||||
| 						} else if ((dt == DT_ISO_FAT) && (!iso_report.has_isolinux)) { | ||||
| 							MessageBoxA(hMainDialog, "Only 'isolinux' based ISO " | ||||
| 								"images can be used with FAT.", "Unsupported ISO...", MB_OK|MB_ICONERROR); | ||||
| 							break; | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				GetWindowTextA(hDeviceList, tmp, sizeof(tmp)); | ||||
|  |  | |||
							
								
								
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										12
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL | |||
| IDD_DIALOG DIALOGEX 12, 12, 206, 278 | ||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||
| EXSTYLE WS_EX_APPWINDOW | ||||
| CAPTION "Rufus v1.1.1.134" | ||||
| CAPTION "Rufus v1.1.1.135" | ||||
| FONT 8, "MS Shell Dlg", 400, 0, 0x1 | ||||
| BEGIN | ||||
|     DEFPUSHBUTTON   "Start",IDC_START,94,236,50,14 | ||||
|  | @ -71,7 +71,7 @@ BEGIN | |||
|     DEFPUSHBUTTON   "OK",IDOK,231,175,50,14,WS_GROUP | ||||
|     CONTROL         "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL, | ||||
|                     "SysLink",WS_TABSTOP,46,47,114,9 | ||||
|     LTEXT           "Version 1.1.1 (Build 134)",IDC_STATIC,46,19,78,8 | ||||
|     LTEXT           "Version 1.1.1 (Build 135)",IDC_STATIC,46,19,78,8 | ||||
|     PUSHBUTTON      "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP | ||||
|     EDITTEXT        IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL | ||||
|     LTEXT           "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 | ||||
|  | @ -222,8 +222,8 @@ END | |||
| // | ||||
| 
 | ||||
| VS_VERSION_INFO VERSIONINFO | ||||
|  FILEVERSION 1,1,1,134 | ||||
|  PRODUCTVERSION 1,1,1,134 | ||||
|  FILEVERSION 1,1,1,135 | ||||
|  PRODUCTVERSION 1,1,1,135 | ||||
|  FILEFLAGSMASK 0x3fL | ||||
| #ifdef _DEBUG | ||||
|  FILEFLAGS 0x1L | ||||
|  | @ -240,13 +240,13 @@ BEGIN | |||
|         BEGIN | ||||
|             VALUE "CompanyName", "akeo.ie" | ||||
|             VALUE "FileDescription", "Rufus" | ||||
|             VALUE "FileVersion", "1.1.1.134" | ||||
|             VALUE "FileVersion", "1.1.1.135" | ||||
|             VALUE "InternalName", "Rufus" | ||||
|             VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" | ||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||
|             VALUE "OriginalFilename", "rufus.exe" | ||||
|             VALUE "ProductName", "Rufus" | ||||
|             VALUE "ProductVersion", "1.1.1.134" | ||||
|             VALUE "ProductVersion", "1.1.1.135" | ||||
|         END | ||||
|     END | ||||
|     BLOCK "VarFileInfo" | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue