- Timestamp:
- Jul 31, 2017 8:28:23 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r68140 r68184 38 38 #include <iprt/buildconfig.h> 39 39 #include <iprt/ctype.h> 40 #include <iprt/file.h> 41 #include <iprt/getopt.h> 40 42 #include <iprt/initterm.h> 41 43 #include <iprt/path.h> … … 460 462 * the support driver. 461 463 */ 462 RTR3InitExe(argc, &argv, 0); 464 int vrc = RTR3InitExe(argc, &argv, 0); 465 if (RT_FAILURE(vrc)) 466 return RTMsgInitFailure(vrc); 463 467 #if defined(RT_OS_WINDOWS) && !defined(VBOX_ONLY_DOCS) 464 468 ATL::CComModule _Module; /* Required internally by ATL (constructor records instance in global variable). */ … … 474 478 const char *pszSettingsPw = NULL; 475 479 const char *pszSettingsPwFile = NULL; 480 #ifndef VBOX_ONLY_DOCS 481 int cResponseFileArgs = 0; 482 char **papszResponseFileArgs = NULL; 483 char **papszNewArgv = NULL; 484 #endif 476 485 477 486 for (int i = 1; i < argc || argc <= iCmd; i++) … … 548 557 iCmd += 2; 549 558 } 559 #ifndef VBOX_ONLY_DOCS 560 else if (argv[i][0] == '@') 561 { 562 if (papszResponseFileArgs) 563 return RTMsgErrorExitFailure("Only one response file allowed"); 564 565 /* Load response file, making sure it's valid UTF-8. */ 566 char *pszResponseFile; 567 size_t cbResponseFile; 568 vrc = RTFileReadAllEx(&argv[i][1], 0, RTFOFF_MAX, RTFILE_RDALL_O_DENY_NONE | RTFILE_RDALL_F_TRAILING_ZERO_BYTE, 569 (void **)&pszResponseFile, &cbResponseFile); 570 if (RT_FAILURE(vrc)) 571 return RTMsgErrorExitFailure("Error reading response file '%s': %Rrc", &argv[i][1], vrc); 572 vrc = RTStrValidateEncoding(pszResponseFile); 573 if (RT_FAILURE(vrc)) 574 { 575 RTFileReadAllFree(pszResponseFile, cbResponseFile); 576 return RTMsgErrorExitFailure("Invalid response file ('%s') encoding: %Rrc", &argv[i][1], vrc); 577 } 578 579 /* Parse it. */ 580 vrc = RTGetOptArgvFromString(&papszResponseFileArgs, &cResponseFileArgs, pszResponseFile, 581 RTGETOPTARGV_CNV_QUOTE_BOURNE_SH, NULL); 582 RTFileReadAllFree(pszResponseFile, cbResponseFile); 583 if (RT_FAILURE(vrc)) 584 return RTMsgErrorExitFailure("Failed to parse response file '%s' (bourne shell style): %Rrc", &argv[i][1], vrc); 585 586 /* Construct new argv+argc with the response file arguments inserted. */ 587 int cNewArgs = argc + cResponseFileArgs; 588 papszNewArgv = (char **)RTMemAllocZ((cNewArgs + 2) * sizeof(papszNewArgv[0])); 589 if (!papszNewArgv) 590 return RTMsgErrorExitFailure("out of memory"); 591 memcpy(&papszNewArgv[0], &argv[0], sizeof(argv[0]) * (i + 1)); 592 memcpy(&papszNewArgv[i + 1], papszResponseFileArgs, sizeof(argv[0]) * cResponseFileArgs); 593 memcpy(&papszNewArgv[i + 1 + cResponseFileArgs], &argv[i + 1], sizeof(argv[0]) * (argc - i - 1 + 1)); 594 argv = papszNewArgv; 595 argc = argc + cResponseFileArgs; 596 597 iCmd++; 598 } 599 #endif 550 600 else 551 601 break; … … 697 747 } 698 748 749 if (papszResponseFileArgs) 750 { 751 RTGetOptArgvFree(papszResponseFileArgs); 752 RTMemFree(papszNewArgv); 753 } 754 699 755 return rcExit; 700 756 #else /* VBOX_ONLY_DOCS */
Note:
See TracChangeset
for help on using the changeset viewer.