mirror of
				https://github.com/pbatard/rufus.git
				synced 2024-08-14 23:57:05 +00:00 
			
		
		
		
	[misc] add a few more missing calloc checks
* Also use the relevant macro in msapi_utf8.h
This commit is contained in:
		
							parent
							
								
									a10ea1498b
								
							
						
					
					
						commit
						c0393aec08
					
				
					 3 changed files with 72 additions and 66 deletions
				
			
		|  | @ -561,7 +561,7 @@ static __inline int SHDeleteDirectoryExU(HWND hwnd, const char* pszPath, FILEOP_ | ||||||
| 	// String needs to be double NULL terminated, so we just use the length of the UTF-8 string
 | 	// String needs to be double NULL terminated, so we just use the length of the UTF-8 string
 | ||||||
| 	// which is always expected to be larger than our UTF-16 one, and add 2 chars for good measure.
 | 	// which is always expected to be larger than our UTF-16 one, and add 2 chars for good measure.
 | ||||||
| 	size_t wpszPath_len = strlen(pszPath) + 2; | 	size_t wpszPath_len = strlen(pszPath) + 2; | ||||||
| 	wchar_t* wpszPath = (wchar_t*)calloc(wpszPath_len, sizeof(wchar_t)); | 	walloc(pszPath, wpszPath_len); | ||||||
| 	SHFILEOPSTRUCTW shfo = { hwnd, FO_DELETE, wpszPath, NULL, fFlags, FALSE, NULL, NULL }; | 	SHFILEOPSTRUCTW shfo = { hwnd, FO_DELETE, wpszPath, NULL, fFlags, FALSE, NULL, NULL }; | ||||||
| 	utf8_to_wchar_no_alloc(pszPath, wpszPath, (int)wpszPath_len); | 	utf8_to_wchar_no_alloc(pszPath, wpszPath, (int)wpszPath_len); | ||||||
| 	// FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION,
 | 	// FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION,
 | ||||||
|  |  | ||||||
							
								
								
									
										126
									
								
								src/rufus.c
									
										
									
									
									
								
							
							
						
						
									
										126
									
								
								src/rufus.c
									
										
									
									
									
								
							|  | @ -2755,15 +2755,17 @@ static HANDLE SetHogger(BOOL attached_console, BOOL disable_hogger) | ||||||
| 
 | 
 | ||||||
| 		// Now launch the file from the commandline, by simulating keypresses
 | 		// Now launch the file from the commandline, by simulating keypresses
 | ||||||
| 		input = (INPUT*)calloc(strlen(cmdline_hogger)+1, sizeof(INPUT)); | 		input = (INPUT*)calloc(strlen(cmdline_hogger)+1, sizeof(INPUT)); | ||||||
| 		for (i=0; i<(int)strlen(cmdline_hogger); i++) { | 		if (input != NULL) { | ||||||
|  | 			for (i = 0; i < (int)strlen(cmdline_hogger); i++) { | ||||||
|  | 				input[i].type = INPUT_KEYBOARD; | ||||||
|  | 				input[i].ki.dwFlags = KEYEVENTF_UNICODE; | ||||||
|  | 				input[i].ki.wScan = (wchar_t)cmdline_hogger[i]; | ||||||
|  | 			} | ||||||
| 			input[i].type = INPUT_KEYBOARD; | 			input[i].type = INPUT_KEYBOARD; | ||||||
| 			input[i].ki.dwFlags = KEYEVENTF_UNICODE; | 			input[i].ki.wVk = VK_RETURN; | ||||||
| 			input[i].ki.wScan = (wchar_t)cmdline_hogger[i]; | 			SendInput(i + 1, input, sizeof(INPUT)); | ||||||
|  | 			free(input); | ||||||
| 		} | 		} | ||||||
| 		input[i].type = INPUT_KEYBOARD; |  | ||||||
| 		input[i].ki.wVk = VK_RETURN; |  | ||||||
| 		SendInput(i+1, input, sizeof(INPUT)); |  | ||||||
| 		safe_free(input); |  | ||||||
| 	} | 	} | ||||||
| 	if (hogmutex != NULL) | 	if (hogmutex != NULL) | ||||||
| 		Sleep(200);	// Need to add a delay, otherwise we may get some printout before the hogger
 | 		Sleep(200);	// Need to add a delay, otherwise we may get some printout before the hogger
 | ||||||
|  | @ -2867,63 +2869,67 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine | ||||||
| 	if (pf__wgetmainargs != NULL) { | 	if (pf__wgetmainargs != NULL) { | ||||||
| 		pf__wgetmainargs(&argc, &wargv, &wenv, 1, &si); | 		pf__wgetmainargs(&argc, &wargv, &wenv, 1, &si); | ||||||
| 		argv = (char**)calloc(argc, sizeof(char*)); | 		argv = (char**)calloc(argc, sizeof(char*)); | ||||||
|  | 		if (argv != NULL) { | ||||||
|  | 			// Non getopt parameter check
 | ||||||
|  | 			for (i = 0; i < argc; i++) { | ||||||
|  | 				argv[i] = wchar_to_utf8(wargv[i]); | ||||||
|  | 				// Check for " /W" (wait for mutex release for pre 1.3.3 versions)
 | ||||||
|  | 				if (strcmp(argv[i], "/W") == 0) | ||||||
|  | 					wait_for_mutex = 150;	// Try to acquire the mutex for 15 seconds
 | ||||||
|  | 				// We need to find if we need to disable the hogger BEFORE we start
 | ||||||
|  | 				// processing arguments with getopt, as we may want to print messages
 | ||||||
|  | 				// on the commandline then, which the hogger makes more intuitive.
 | ||||||
|  | 				if ((strcmp(argv[i], "-g") == 0) || (strcmp(argv[i], "--gui") == 0)) | ||||||
|  | 					disable_hogger = TRUE; | ||||||
|  | 			} | ||||||
| 
 | 
 | ||||||
| 		// Non getopt parameter check
 | 			// If our application name contains a 'p' (for "portable") create a 'rufus.ini'
 | ||||||
| 		for (i=0; i<argc; i++) { | 			// NB: argv[0] is populated in the previous loop
 | ||||||
| 			argv[i] = wchar_to_utf8(wargv[i]); | 			tmp = &argv[0][strlen(argv[0]) - 1]; | ||||||
| 			// Check for " /W" (wait for mutex release for pre 1.3.3 versions)
 | 			while ((((uintptr_t)tmp) > ((uintptr_t)argv[0])) && (*tmp != '\\')) | ||||||
| 			if (strcmp(argv[i], "/W") == 0) | 				tmp--; | ||||||
| 				wait_for_mutex = 150;	// Try to acquire the mutex for 15 seconds
 | 			if ((strchr(tmp, 'p') != NULL) || (strchr(tmp, 'P') != NULL)) | ||||||
| 			// We need to find if we need to disable the hogger BEFORE we start
 | 				ini_flags[0] = 'a'; | ||||||
| 			// processing arguments with getopt, as we may want to print messages
 |  | ||||||
| 			// on the commandline then, which the hogger makes more intuitive.
 |  | ||||||
| 			if ((strcmp(argv[i], "-g") == 0) || (strcmp(argv[i], "--gui") == 0)) |  | ||||||
| 				disable_hogger = TRUE; |  | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		// If our application name contains a 'p' (for "portable") create a 'rufus.ini'
 | 			// Now enable the hogger before processing the rest of the arguments
 | ||||||
| 		// NB: argv[0] is populated in the previous loop
 | 			hogmutex = SetHogger(attached_console, disable_hogger); | ||||||
| 		tmp = &argv[0][strlen(argv[0]) -1]; |  | ||||||
| 		while ((((uintptr_t)tmp)>((uintptr_t)argv[0])) && (*tmp != '\\')) |  | ||||||
| 			tmp--; |  | ||||||
| 		if ((strchr(tmp, 'p') != NULL) || (strchr(tmp, 'P') != NULL)) |  | ||||||
| 			ini_flags[0] = 'a'; |  | ||||||
| 
 | 
 | ||||||
| 		// Now enable the hogger before processing the rest of the arguments
 | 			while ((opt = getopt_long(argc, argv, "?fghi:w:l:", long_options, &option_index)) != EOF) { | ||||||
| 		hogmutex = SetHogger(attached_console, disable_hogger); | 				switch (opt) { | ||||||
| 
 | 				case 'f': | ||||||
| 		while ((opt = getopt_long(argc, argv, "?fghi:w:l:", long_options, &option_index)) != EOF) | 					enable_HDDs = TRUE; | ||||||
| 			switch (opt) { | 					break; | ||||||
| 			case 'f': | 				case 'g': | ||||||
| 				enable_HDDs = TRUE; | 					// No need to reprocess that option
 | ||||||
| 				break; | 					break; | ||||||
| 			case 'g': | 				case 'i': | ||||||
| 				// No need to reprocess that option
 | 					if (_access(optarg, 0) != -1) { | ||||||
| 				break; | 						image_path = safe_strdup(optarg); | ||||||
| 			case 'i': | 						iso_provided = TRUE; | ||||||
| 				if (_access(optarg, 0) != -1) { | 					} | ||||||
| 					image_path = safe_strdup(optarg); | 					else { | ||||||
| 					iso_provided = TRUE; | 						printf("Could not find ISO image '%s'\n", optarg); | ||||||
| 				} else { | 					} | ||||||
| 					printf("Could not find ISO image '%s'\n", optarg); | 					break; | ||||||
|  | 				case 'l': | ||||||
|  | 					if (isdigitU(optarg[0])) { | ||||||
|  | 						lcid = (int)strtol(optarg, NULL, 0); | ||||||
|  | 					} | ||||||
|  | 					else { | ||||||
|  | 						safe_free(locale_name); | ||||||
|  | 						locale_name = safe_strdup(optarg); | ||||||
|  | 					} | ||||||
|  | 					break; | ||||||
|  | 				case 'w': | ||||||
|  | 					wait_for_mutex = atoi(optarg); | ||||||
|  | 					break; | ||||||
|  | 				case '?': | ||||||
|  | 				case 'h': | ||||||
|  | 				default: | ||||||
|  | 					PrintUsage(argv[0]); | ||||||
|  | 					goto out; | ||||||
| 				} | 				} | ||||||
| 				break; | 			} | ||||||
| 			case 'l': |  | ||||||
| 				if (isdigitU(optarg[0])) { |  | ||||||
| 					lcid = (int)strtol(optarg, NULL, 0); |  | ||||||
| 				} else { |  | ||||||
| 					safe_free(locale_name); |  | ||||||
| 					locale_name =safe_strdup(optarg); |  | ||||||
| 				} |  | ||||||
| 				break; |  | ||||||
| 			case 'w': |  | ||||||
| 				wait_for_mutex = atoi(optarg); |  | ||||||
| 				break; |  | ||||||
| 			case '?': |  | ||||||
| 			case 'h': |  | ||||||
| 			default: |  | ||||||
| 				PrintUsage(argv[0]); |  | ||||||
| 				goto out; |  | ||||||
| 		} | 		} | ||||||
| 	} else { | 	} else { | ||||||
| 		uprintf("Could not access UTF-16 args"); | 		uprintf("Could not access UTF-16 args"); | ||||||
|  |  | ||||||
							
								
								
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							
							
						
						
									
										10
									
								
								src/rufus.rc
									
										
									
									
									
								
							|  | @ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL | ||||||
| IDD_DIALOG DIALOGEX 12, 12, 242, 376 | IDD_DIALOG DIALOGEX 12, 12, 242, 376 | ||||||
| STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU | ||||||
| EXSTYLE WS_EX_ACCEPTFILES | EXSTYLE WS_EX_ACCEPTFILES | ||||||
| CAPTION "Rufus 2.10.955" | CAPTION "Rufus 2.10.956" | ||||||
| FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | FONT 8, "Segoe UI Symbol", 400, 0, 0x0 | ||||||
| BEGIN | BEGIN | ||||||
|     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 |     LTEXT           "Device",IDS_DEVICE_TXT,9,6,200,8 | ||||||
|  | @ -320,8 +320,8 @@ END | ||||||
| // | // | ||||||
| 
 | 
 | ||||||
| VS_VERSION_INFO VERSIONINFO | VS_VERSION_INFO VERSIONINFO | ||||||
|  FILEVERSION 2,10,955,0 |  FILEVERSION 2,10,956,0 | ||||||
|  PRODUCTVERSION 2,10,955,0 |  PRODUCTVERSION 2,10,956,0 | ||||||
|  FILEFLAGSMASK 0x3fL |  FILEFLAGSMASK 0x3fL | ||||||
| #ifdef _DEBUG | #ifdef _DEBUG | ||||||
|  FILEFLAGS 0x1L |  FILEFLAGS 0x1L | ||||||
|  | @ -338,13 +338,13 @@ BEGIN | ||||||
|         BEGIN |         BEGIN | ||||||
|             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" |             VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" | ||||||
|             VALUE "FileDescription", "Rufus" |             VALUE "FileDescription", "Rufus" | ||||||
|             VALUE "FileVersion", "2.10.955" |             VALUE "FileVersion", "2.10.956" | ||||||
|             VALUE "InternalName", "Rufus" |             VALUE "InternalName", "Rufus" | ||||||
|             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" |             VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" | ||||||
|             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" |             VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" | ||||||
|             VALUE "OriginalFilename", "rufus.exe" |             VALUE "OriginalFilename", "rufus.exe" | ||||||
|             VALUE "ProductName", "Rufus" |             VALUE "ProductName", "Rufus" | ||||||
|             VALUE "ProductVersion", "2.10.955" |             VALUE "ProductVersion", "2.10.956" | ||||||
|         END |         END | ||||||
|     END |     END | ||||||
|     BLOCK "VarFileInfo" |     BLOCK "VarFileInfo" | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue