Fix crash when specifying invalid argument for --autocomplete

Coverity Bug ID: 1167734
This commit is contained in:
Gunnar Beutner 2015-03-03 09:23:38 +01:00
parent 3e12bfef25
commit ba6b92a929
1 changed files with 9 additions and 1 deletions

View File

@ -96,7 +96,15 @@ int Main(void)
if (argc >= 4 && strcmp(argv[1], "--autocomplete") == 0) {
autocomplete = true;
autoindex = Convert::ToLong(argv[2]);
try {
autoindex = Convert::ToLong(argv[2]);
} catch (const std::invalid_argument& ex) {
Log(LogCritical, "icinga-app")
<< "Invalid index for --autocomplete: " << argv[2];
return EXIT_FAILURE;
}
argc -= 3;
argv += 3;
}